rust/tests/ui/array-slice-vec/vec-matching-fixed.rs

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

31 lines
540 B
Rust
Raw Normal View History

// run-pass
fn a() {
2015-01-25 21:05:03 +00:00
let x = [1, 2, 3];
match x {
[1, 2, 4] => unreachable!(),
2013-11-28 20:22:53 +00:00
[0, 2, 3, ..] => unreachable!(),
[0, .., 3] => unreachable!(),
[0, ..] => unreachable!(),
[1, 2, 3] => (),
[_, _, _] => unreachable!(),
}
match x {
2013-11-28 20:22:53 +00:00
[..] => (),
}
match x {
2013-11-28 20:22:53 +00:00
[_, _, _, ..] => (),
}
match x {
[a, b, c] => {
assert_eq!(1, a);
assert_eq!(2, b);
assert_eq!(3, c);
}
}
}
pub fn main() {
a();
}