1 # `advanced_slice_patterns`
3 The tracking issue for this feature is: [#23121]
5 [#23121]: https://github.com/rust-lang/rust/issues/23121
7 See also [`slice_patterns`](slice-patterns.html).
9 ------------------------
12 The `advanced_slice_patterns` gate lets you use `..` to indicate any number of
13 elements inside a pattern matching a slice. This wildcard can only be used once
14 for a given array. If there's an identifier before the `..`, the result of the
15 slice will be bound to that name. For example:
18 #![feature(advanced_slice_patterns, slice_patterns)]
20 fn is_symmetric(list: &[u32]) -> bool {
23 &[x, ref inside.., y] if x == y => is_symmetric(inside),
29 let sym = &[0, 1, 4, 2, 4, 1, 0];
30 assert!(is_symmetric(sym));
32 let not_sym = &[0, 1, 7, 2, 4, 1, 0];
33 assert!(!is_symmetric(not_sym));