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

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

24 lines
523 B
Rust
Raw Normal View History

// run-pass
#![allow(illegal_floating_point_literal_pattern)] // FIXME #41620
pub fn main() {
2015-01-25 21:05:03 +00:00
let x = [1, 2, 3];
2012-12-15 23:13:55 +00:00
match x {
[2, _, _] => panic!(),
[1, a, b] => {
assert_eq!([a, b], [2, 3]);
2012-12-15 23:13:55 +00:00
}
[_, _, _] => panic!(),
2012-12-15 23:13:55 +00:00
}
2015-01-25 21:05:03 +00:00
let y = ([(1, true), (2, false)], 0.5f64);
2012-12-15 23:13:55 +00:00
match y {
([(1, a), (b, false)], _) => {
assert_eq!(a, true);
assert_eq!(b, 2);
2012-12-15 23:13:55 +00:00
}
([_, _], 0.5) => panic!(),
([_, _], _) => panic!(),
2012-12-15 23:13:55 +00:00
}
}