blob: b0d89e038aa8b19b95e19b65eb142b203f4ce353 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#![warn(clippy::if_chain_style)]
#![allow(clippy::no_effect, clippy::nonminimal_bool, clippy::missing_clippy_version_attribute)]
extern crate if_chain;
use if_chain::if_chain;
fn main() {
if true {
let x = "";
// `if_chain!` inside `if`
if_chain! {
if true;
if true;
then {}
}
}
if_chain! {
if true
// multi-line AND'ed conditions
&& false;
if let Some(1) = Some(1);
// `let` before `then`
let x = "";
then {
();
}
}
if_chain! {
// single `if` condition
if true;
then {
let x = "";
// nested if
if true {}
}
}
if_chain! {
// starts with `let ..`
let x = "";
if let Some(1) = Some(1);
then {
let x = "";
let x = "";
// nested if_chain!
if_chain! {
if true;
if true;
then {}
}
}
}
}
fn negative() {
if true {
();
if_chain! {
if true;
if true;
then { (); }
}
}
if_chain! {
if true;
let x = "";
if true;
then { (); }
}
if_chain! {
if true;
if true;
then {
if true { 1 } else { 2 }
} else {
3
}
};
if true {
if_chain! {
if true;
if true;
then {}
}
} else if false {
if_chain! {
if true;
if false;
then {}
}
}
}
|