]> git.lizzy.rs Git - rust.git/blob - src/test/ui/or-patterns/box-patterns.rs
Auto merge of #68915 - timvermeulen:non_fused_iter, r=Amanieu
[rust.git] / src / test / ui / or-patterns / box-patterns.rs
1 // Test or-patterns with box-patterns
2
3 // run-pass
4
5 #![feature(or_patterns)]
6 #![feature(box_patterns)]
7
8 #[derive(Debug, PartialEq)]
9 enum MatchArm {
10     Arm(usize),
11     Wild,
12 }
13
14 #[derive(Debug)]
15 enum Test {
16     Foo,
17     Bar,
18     Baz,
19     Qux,
20 }
21
22 fn test(x: Option<Box<Test>>) -> MatchArm {
23     match x {
24         Some(box Test::Foo | box Test::Bar) => MatchArm::Arm(0),
25         Some(box Test::Baz) => MatchArm::Arm(1),
26         Some(_) => MatchArm::Arm(2),
27         _ => MatchArm::Wild,
28     }
29 }
30
31 fn main() {
32     assert_eq!(test(Some(Box::new(Test::Foo))), MatchArm::Arm(0));
33     assert_eq!(test(Some(Box::new(Test::Bar))), MatchArm::Arm(0));
34     assert_eq!(test(Some(Box::new(Test::Baz))), MatchArm::Arm(1));
35     assert_eq!(test(Some(Box::new(Test::Qux))), MatchArm::Arm(2));
36     assert_eq!(test(None), MatchArm::Wild);
37 }