]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | // Test basic or-patterns when the target pattern type will be lowered to a |
2 | // `Switch` (an `enum`). | |
3 | ||
4 | // run-pass | |
5 | ||
74b04a01 XL |
6 | #[derive(Debug)] |
7 | enum Test { | |
8 | Foo, | |
9 | Bar, | |
10 | Baz, | |
11 | Qux, | |
12 | } | |
13 | ||
14 | fn test(x: Option<Test>) -> bool { | |
15 | match x { | |
16 | // most simple case | |
17 | Some(Test::Bar | Test::Qux) => true, | |
18 | // wild case | |
19 | Some(_) => false, | |
20 | // empty case | |
21 | None => false, | |
22 | } | |
23 | } | |
24 | ||
25 | fn main() { | |
26 | assert!(!test(Some(Test::Foo))); | |
27 | assert!(test(Some(Test::Bar))); | |
28 | assert!(!test(Some(Test::Baz))); | |
29 | assert!(test(Some(Test::Qux))); | |
30 | assert!(!test(None)) | |
31 | } |