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