]>
Commit | Line | Data |
---|---|---|
fc512014 XL |
1 | // run-pass |
2 | ||
3 | #![feature(if_let_guard)] | |
fc512014 XL |
4 | |
5 | enum Foo { | |
6 | Bar, | |
7 | Baz, | |
8 | Qux(u8), | |
9 | } | |
10 | ||
11 | fn bar(x: bool) -> Foo { | |
12 | if x { Foo::Baz } else { Foo::Bar } | |
13 | } | |
14 | ||
15 | fn baz(x: u8) -> Foo { | |
16 | if x % 2 == 0 { Foo::Bar } else { Foo::Baz } | |
17 | } | |
18 | ||
19 | fn qux(x: u8) -> Foo { | |
20 | Foo::Qux(x.rotate_left(1)) | |
21 | } | |
22 | ||
23 | fn main() { | |
24 | match Some((true, 3)) { | |
25 | Some((x, _)) if let Foo::Bar = bar(x) => panic!(), | |
26 | Some((_, x)) if let Foo::Baz = baz(x) => {}, | |
27 | _ => panic!(), | |
28 | } | |
29 | match Some(42) { | |
30 | Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84), | |
31 | _ => panic!(), | |
32 | } | |
33 | } |