2013-03-11 05:53:41 -05:00
|
|
|
fn a() {
|
2013-02-26 12:58:46 -06:00
|
|
|
let x = [1];
|
2012-12-08 14:22:43 -06:00
|
|
|
match x {
|
2013-02-26 12:58:46 -06:00
|
|
|
[_, _, _, _, _, .._] => ::core::util::unreachable(),
|
|
|
|
[.._, _, _, _, _] => ::core::util::unreachable(),
|
|
|
|
[_, .._, _, _] => ::core::util::unreachable(),
|
|
|
|
[_, _] => ::core::util::unreachable(),
|
|
|
|
[a] => {
|
2013-03-28 20:39:09 -05:00
|
|
|
assert!(a == 1);
|
2012-12-08 14:22:43 -06:00
|
|
|
}
|
2013-02-26 12:58:46 -06:00
|
|
|
[] => ::core::util::unreachable()
|
2012-12-08 14:22:43 -06:00
|
|
|
}
|
|
|
|
}
|
2013-03-11 05:53:41 -05:00
|
|
|
|
|
|
|
fn b() {
|
|
|
|
let x = [1, 2, 3];
|
|
|
|
match x {
|
|
|
|
[a, b, ..c] => {
|
2013-03-28 20:39:09 -05:00
|
|
|
assert!(a == 1);
|
|
|
|
assert!(b == 2);
|
|
|
|
assert!(c == &[3]);
|
2013-03-11 05:53:41 -05:00
|
|
|
}
|
|
|
|
_ => fail!()
|
|
|
|
}
|
|
|
|
match x {
|
|
|
|
[..a, b, c] => {
|
2013-03-28 20:39:09 -05:00
|
|
|
assert!(a == &[1]);
|
|
|
|
assert!(b == 2);
|
|
|
|
assert!(c == 3);
|
2013-03-11 05:53:41 -05:00
|
|
|
}
|
|
|
|
_ => fail!()
|
|
|
|
}
|
|
|
|
match x {
|
|
|
|
[a, ..b, c] => {
|
2013-03-28 20:39:09 -05:00
|
|
|
assert!(a == 1);
|
|
|
|
assert!(b == &[2]);
|
|
|
|
assert!(c == 3);
|
2013-03-11 05:53:41 -05:00
|
|
|
}
|
|
|
|
_ => fail!()
|
|
|
|
}
|
|
|
|
match x {
|
|
|
|
[a, b, c] => {
|
2013-03-28 20:39:09 -05:00
|
|
|
assert!(a == 1);
|
|
|
|
assert!(b == 2);
|
|
|
|
assert!(c == 3);
|
2013-03-11 05:53:41 -05:00
|
|
|
}
|
|
|
|
_ => fail!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
a();
|
|
|
|
b();
|
|
|
|
}
|