]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/target/one_line_if_v1.rs
Merge commit '39683d8eb7a32a74bea96ecbf1e87675d3338506' into sync_cg_gcc-2022-03-26
[rust.git] / src / tools / rustfmt / tests / target / one_line_if_v1.rs
1 // rustfmt-version: One
2
3 fn plain_if(x: bool) -> u8 {
4     if x {
5         0
6     } else {
7         1
8     }
9 }
10
11 fn paren_if(x: bool) -> u8 {
12     (if x { 0 } else { 1 })
13 }
14
15 fn let_if(x: bool) -> u8 {
16     let x = if x { foo() } else { bar() };
17     x
18 }
19
20 fn return_if(x: bool) -> u8 {
21     return if x { 0 } else { 1 };
22 }
23
24 fn multi_if() {
25     use std::io;
26     if x {
27         foo()
28     } else {
29         bar()
30     }
31     if x {
32         foo()
33     } else {
34         bar()
35     }
36 }
37
38 fn middle_if() {
39     use std::io;
40     if x {
41         foo()
42     } else {
43         bar()
44     }
45     let x = 1;
46 }