summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/try_block.rs
blob: 2e8d61f7e66a5a2c35ba6e947f279fae89d9b7dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// rustfmt-edition: 2018

fn main() -> Result<(), !> {
    let _x: Option<_> = try {
        4
    };

    try {}
}

fn baz() -> Option<i32> {
    if (1 == 1) {
        return try {
            5
        };
    }

    // test
    let x: Option<()> = try {
        // try blocks are great
    };

    let y: Option<i32> = try {
        6
    }; // comment

    let x: Option<i32> = try { baz()?; baz()?; baz()?; 7 };

    return None;
}