]> git.proxmox.com Git - rustc.git/blame - src/test/ui/array-slice-vec/vec-tail-matching.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / array-slice-vec / vec-tail-matching.rs
CommitLineData
b7449926
XL
1// run-pass
2
223e47cc 3struct Foo {
3157f602 4 string: &'static str
223e47cc
LB
5}
6
7pub fn main() {
8 let x = [
3157f602
XL
9 Foo { string: "foo" },
10 Foo { string: "bar" },
11 Foo { string: "baz" }
223e47cc
LB
12 ];
13 match x {
416331ca 14 [ref first, ref tail @ ..] => {
3157f602 15 assert_eq!(first.string, "foo");
970d7e83 16 assert_eq!(tail.len(), 2);
3157f602
XL
17 assert_eq!(tail[0].string, "bar");
18 assert_eq!(tail[1].string, "baz");
223e47cc 19
3157f602 20 match *(tail as &[_]) {
416331ca 21 [Foo { .. }, _, Foo { .. }, ref _tail @ ..] => {
1a4d82fc 22 unreachable!();
223e47cc 23 }
970d7e83 24 [Foo { string: ref a }, Foo { string: ref b }] => {
85aaf69f
SL
25 assert_eq!("bar", &a[0..a.len()]);
26 assert_eq!("baz", &b[0..b.len()]);
223e47cc
LB
27 }
28 _ => {
1a4d82fc 29 unreachable!();
223e47cc
LB
30 }
31 }
32 }
223e47cc
LB
33 }
34}