rust/src/test/ui/issues/issue-15080.rs

24 lines
450 B
Rust
Raw Normal View History

// run-pass
#![feature(slice_patterns)]
fn main() {
2015-01-25 15:05:03 -06:00
let mut x: &[_] = &[1, 2, 3, 4];
let mut result = vec![];
loop {
x = match *x {
[1, n, 3, ref rest..] => {
result.push(n);
rest
}
[n, ref rest..] => {
result.push(n);
rest
}
[] =>
break
}
}
assert_eq!(result, [2, 4]);
}