2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
2015-03-27 01:34:27 +00:00
|
|
|
|
2014-06-21 12:52:23 +00:00
|
|
|
fn main() {
|
2015-01-25 21:05:03 +00:00
|
|
|
let mut x: &[_] = &[1, 2, 3, 4];
|
2014-06-21 12:52:23 +00:00
|
|
|
|
2016-10-29 21:54:04 +00:00
|
|
|
let mut result = vec![];
|
2014-06-21 12:52:23 +00:00
|
|
|
loop {
|
2016-03-11 10:54:59 +00:00
|
|
|
x = match *x {
|
2019-07-07 23:47:46 +00:00
|
|
|
[1, n, 3, ref rest @ ..] => {
|
2014-06-21 12:52:23 +00:00
|
|
|
result.push(n);
|
|
|
|
rest
|
|
|
|
}
|
2019-07-07 23:47:46 +00:00
|
|
|
[n, ref rest @ ..] => {
|
2014-06-21 12:52:23 +00:00
|
|
|
result.push(n);
|
|
|
|
rest
|
|
|
|
}
|
|
|
|
[] =>
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2015-06-07 18:00:38 +00:00
|
|
|
assert_eq!(result, [2, 4]);
|
2014-06-21 12:52:23 +00:00
|
|
|
}
|