]> git.lizzy.rs Git - rust.git/blob - src/test/ui/rfc-2294-if-let-guard/run-pass.rs
Auto merge of #79342 - CDirkx:ipaddr-const, r=oli-obk
[rust.git] / src / test / ui / rfc-2294-if-let-guard / run-pass.rs
1 // run-pass
2
3 #![feature(if_let_guard)]
4 #![allow(incomplete_features)]
5
6 enum Foo {
7     Bar,
8     Baz,
9     Qux(u8),
10 }
11
12 fn bar(x: bool) -> Foo {
13     if x { Foo::Baz } else { Foo::Bar }
14 }
15
16 fn baz(x: u8) -> Foo {
17     if x % 2 == 0 { Foo::Bar } else { Foo::Baz }
18 }
19
20 fn qux(x: u8) -> Foo {
21     Foo::Qux(x.rotate_left(1))
22 }
23
24 fn main() {
25     match Some((true, 3)) {
26         Some((x, _)) if let Foo::Bar = bar(x) => panic!(),
27         Some((_, x)) if let Foo::Baz = baz(x) => {},
28         _ => panic!(),
29     }
30     match Some(42) {
31         Some(x) if let Foo::Qux(y) = qux(x) => assert_eq!(y, 84),
32         _ => panic!(),
33     }
34 }