blob: 98fd793cba2d846821aec70a37a1ab0bf6b59da0 (
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
|
// Format if-else expressions on a single line, when possible.
fn main() {
let a = if 1 > 2 { unreachable!() } else { 10 };
let a = if x {
1
} else if y {
2
} else {
3
};
let b = if cond() {
5
} else {
// Brief comment.
10
};
let c = if cond() {
statement();
5
} else {
10
};
let d = if let Some(val) = turbo {
"cool"
} else {
"beans"
};
if cond() {
statement();
} else {
other_statement();
}
if true {
do_something()
}
let x = if veeeeeeeeery_loooooong_condition() {
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
} else {
bbbbbbbbbb
};
let x = if veeeeeeeeery_loooooong_condition() {
aaaaaaaaaaaaaaaaaaaaaaaaa
} else {
bbbbbbbbbb
};
funk(if test() { 1 } else { 2 }, arg2);
}
|