]> git.lizzy.rs Git - rust.git/blob - src/tools/rustfmt/tests/source/one_line_if_v2.rs
Add 'src/tools/rustfmt/' from commit '7872306edf2e11a69aaffb9434088fd66b46a863'
[rust.git] / src / tools / rustfmt / tests / source / one_line_if_v2.rs
1 // rustfmt-version: Two
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 {
17         foo()
18     } else {
19         bar()
20     };
21     x
22 }
23
24 fn return_if(x: bool) -> u8 {
25     return if x {
26         0
27     } else {
28         1
29     };
30 }
31
32 fn multi_if() {
33     use std::io;
34     if x { foo() } else { bar() }
35     if x { foo() } else { bar() }
36 }
37
38 fn middle_if() {
39     use std::io;
40     if x { foo() } else { bar() }
41     let x = 1;
42 }