2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2017-06-18 02:07:26 -05:00
|
|
|
#![feature(box_patterns)]
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
enum Test {
|
|
|
|
Foo(usize),
|
|
|
|
Bar(isize),
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2022-07-06 21:36:10 -05:00
|
|
|
let a = Box::new(Test::Foo(10));
|
|
|
|
let b = Box::new(Test::Bar(-20));
|
2017-06-18 02:07:26 -05:00
|
|
|
match (a, b) {
|
|
|
|
(_, box Test::Foo(_)) => unreachable!(),
|
|
|
|
(box Test::Foo(x), b) => {
|
|
|
|
assert_eq!(x, 10);
|
2022-07-06 21:36:10 -05:00
|
|
|
assert_eq!(b, Box::new(Test::Bar(-20)));
|
2017-06-18 02:07:26 -05:00
|
|
|
},
|
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|