4 #[warn(collapsible_if)]
10 println!("Hello world!");
14 if x == "hello" || x == "world" {
15 if y == "world" || y == "hello" {
16 println!("Hello world!");
20 if x == "hello" && x == "world" {
21 if y == "world" || y == "hello" {
22 println!("Hello world!");
26 if x == "hello" || x == "world" {
27 if y == "world" && y == "hello" {
28 println!("Hello world!");
32 if x == "hello" && x == "world" {
33 if y == "world" && y == "hello" {
34 println!("Hello world!");
44 // Collapse `else { if .. }` to `else if ..`
56 if let Some(42) = Some(42) {
75 if let Some(42) = Some(42) {
83 if let Some(42) = Some(42) {
86 if let Some(42) = Some(42) {
94 if let Some(42) = Some(42) {
105 if let Some(42) = Some(42) {
108 if let Some(42) = Some(42) {
116 // Works because any if with an else statement cannot be collapsed.
119 println!("Hello world!");
122 println!("Not Hello world");
127 println!("Hello world!");
129 println!("Hello something else");
142 assert!(true); // assert! is just an `if`