]> git.proxmox.com Git - rustc.git/blame - src/test/ui/or-patterns/basic-switch.rs
New upstream version 1.53.0+dfsg1
[rustc.git] / src / test / ui / or-patterns / basic-switch.rs
CommitLineData
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)]
7enum Test {
8 Foo,
9 Bar,
10 Baz,
11 Qux,
12}
13
14fn 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
25fn 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}