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