]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/source/single-line-if-else.rs
Rollup merge of #100804 - GuillaumeGomez:search-results-color-ayu, r=notriddle
[rust.git] / src / tools / rustfmt / tests / source / single-line-if-else.rs
1
2 // Format if-else expressions on a single line, when possible.
3
4 fn main() {
5     let a = if 1 > 2 {
6         unreachable!()
7     } else {
8         10
9     };
10
11     let a = if x { 1 } else if y { 2 } else { 3 };
12
13     let b = if cond() {
14         5
15     } else {
16         // Brief comment.
17         10
18     };
19
20     let c = if cond() {
21         statement();
22
23         5
24     } else {
25         10
26     };
27
28     let d   = if  let  Some(val)  =  turbo 
29     { "cool" } else {
30      "beans" };
31
32     if cond() { statement(); } else { other_statement(); }
33
34     if true  {
35         do_something()
36     }
37
38     let x = if veeeeeeeeery_loooooong_condition() { aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa } else { bbbbbbbbbb };
39   
40     let x = if veeeeeeeeery_loooooong_condition()     {    aaaaaaaaaaaaaaaaaaaaaaaaa }   else  {
41         bbbbbbbbbb };
42
43     funk(if test() {
44              1
45          } else {
46              2
47          },
48          arg2);
49 }