rust/src/test/run-pass/vec-matching-fixed.rs

29 lines
527 B
Rust
Raw Normal View History

fn a() {
let x = [1, 2, 3];
match x {
[1, 2, 4] => unreachable!(),
2013-11-28 14:22:53 -06:00
[0, 2, 3, ..] => unreachable!(),
[0, .., 3] => unreachable!(),
[0, ..] => unreachable!(),
[1, 2, 3] => (),
[_, _, _] => unreachable!(),
}
match x {
2013-11-28 14:22:53 -06:00
[..] => (),
}
match x {
2013-11-28 14:22:53 -06:00
[_, _, _, ..] => (),
}
match x {
[a, b, c] => {
assert_eq!(1, a);
assert_eq!(2, b);
assert_eq!(3, c);
}
}
}
pub fn main() {
a();
}