3 If you want to match against a slice or array, you can use `&` with the
4 `slice_patterns` feature:
7 #![feature(slice_patterns)]
10 let v = vec!["match_this", "1"];
13 ["match_this", second] => println!("The second element is {}", second),
19 The `advanced_slice_patterns` gate lets you use `..` to indicate any number of
20 elements inside a pattern matching a slice. This wildcard can only be used once
21 for a given array. If there's an identifier before the `..`, the result of the
22 slice will be bound to that name. For example:
25 #![feature(advanced_slice_patterns, slice_patterns)]
27 fn is_symmetric(list: &[u32]) -> bool {
30 [x, inside.., y] if x == y => is_symmetric(inside),
36 let sym = &[0, 1, 4, 2, 4, 1, 0];
37 assert!(is_symmetric(sym));
39 let not_sym = &[0, 1, 7, 2, 4, 1, 0];
40 assert!(!is_symmetric(not_sym));