mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 09:36:06 +00:00
Add one more test for vector destructuring
This commit is contained in:
parent
9e85589ad3
commit
070137ce90
@ -1,4 +1,4 @@
|
||||
pub fn main() {
|
||||
fn a() {
|
||||
let x = [1];
|
||||
match x {
|
||||
[_, _, _, _, _, .._] => ::core::util::unreachable(),
|
||||
@ -11,3 +11,44 @@ pub fn main() {
|
||||
[] => ::core::util::unreachable()
|
||||
}
|
||||
}
|
||||
|
||||
fn b() {
|
||||
let x = [1, 2, 3];
|
||||
match x {
|
||||
[a, b, ..c] => {
|
||||
fail_unless!(a == 1);
|
||||
fail_unless!(b == 2);
|
||||
fail_unless!(c == &[3]);
|
||||
}
|
||||
_ => fail!()
|
||||
}
|
||||
match x {
|
||||
[..a, b, c] => {
|
||||
fail_unless!(a == &[1]);
|
||||
fail_unless!(b == 2);
|
||||
fail_unless!(c == 3);
|
||||
}
|
||||
_ => fail!()
|
||||
}
|
||||
match x {
|
||||
[a, ..b, c] => {
|
||||
fail_unless!(a == 1);
|
||||
fail_unless!(b == &[2]);
|
||||
fail_unless!(c == 3);
|
||||
}
|
||||
_ => fail!()
|
||||
}
|
||||
match x {
|
||||
[a, b, c] => {
|
||||
fail_unless!(a == 1);
|
||||
fail_unless!(b == 2);
|
||||
fail_unless!(c == 3);
|
||||
}
|
||||
_ => fail!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
a();
|
||||
b();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user