rust/tests/ui/pattern/issue-15080.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
428 B
Rust
Raw Normal View History

// run-pass
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 {
2019-07-07 18:47:46 -05:00
[1, n, 3, ref rest @ ..] => {
result.push(n);
rest
}
2019-07-07 18:47:46 -05:00
[n, ref rest @ ..] => {
result.push(n);
rest
}
[] =>
break
}
}
assert_eq!(result, [2, 4]);
}