]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/bindings-after-at/slice-patterns.rs
VxWorks does provide sigemptyset and sigaddset
[rust.git] / src / test / ui / pattern / bindings-after-at / slice-patterns.rs
1 // Test bindings-after-at with slice-patterns
2
3 // run-pass
4
5 #![feature(bindings_after_at)]
6
7 #[derive(Debug, PartialEq)]
8 enum MatchArm {
9     Arm(usize),
10     Wild,
11 }
12
13 fn test(foo: &[i32]) -> MatchArm {
14     match foo {
15         [bar @ .., n] if n == &5 => {
16             for i in bar {
17                 assert!(i < &5);
18             }
19
20             MatchArm::Arm(0)
21         },
22         bar @ [x0, .., xn] => {
23             assert_eq!(x0, &1);
24             assert_eq!(x0, &1);
25             assert_eq!(xn, &4);
26             assert_eq!(bar, &[1, 2, 3, 4]);
27
28             MatchArm::Arm(1)
29         },
30         _ => MatchArm::Wild,
31     }
32 }
33
34 fn main() {
35     let foo = vec![1, 2, 3, 4, 5];
36
37     assert_eq!(test(&foo), MatchArm::Arm(0));
38     assert_eq!(test(&foo[..4]), MatchArm::Arm(1));
39     assert_eq!(test(&foo[0..1]), MatchArm::Wild);
40 }