]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/single-line-if-else.rs
Merge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component
[rust.git] / src / tools / rustfmt / tests / target / single-line-if-else.rs
1 // Format if-else expressions on a single line, when possible.
2
3 fn main() {
4     let a = if 1 > 2 { unreachable!() } else { 10 };
5
6     let a = if x {
7         1
8     } else if y {
9         2
10     } else {
11         3
12     };
13
14     let b = if cond() {
15         5
16     } else {
17         // Brief comment.
18         10
19     };
20
21     let c = if cond() {
22         statement();
23
24         5
25     } else {
26         10
27     };
28
29     let d = if let Some(val) = turbo {
30         "cool"
31     } else {
32         "beans"
33     };
34
35     if cond() {
36         statement();
37     } else {
38         other_statement();
39     }
40
41     if true {
42         do_something()
43     }
44
45     let x = if veeeeeeeeery_loooooong_condition() {
46         aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
47     } else {
48         bbbbbbbbbb
49     };
50
51     let x = if veeeeeeeeery_loooooong_condition() {
52         aaaaaaaaaaaaaaaaaaaaaaaaa
53     } else {
54         bbbbbbbbbb
55     };
56
57     funk(if test() { 1 } else { 2 }, arg2);
58 }