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