]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/vec-tail-matching.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 #![feature(slice_patterns)]
19 Foo { string: "foo" }
,
20 Foo { string: "bar" }
,
24 [ref first
, ref tail
..] => {
25 assert_eq
!(first
.string
, "foo");
26 assert_eq
!(tail
.len(), 2);
27 assert_eq
!(tail
[0].string
, "bar");
28 assert_eq
!(tail
[1].string
, "baz");
30 match *(tail
as &[_
]) {
31 [Foo { .. }
, _
, Foo { .. }
, ref _tail
..] => {
34 [Foo { string: ref a }
, Foo { string: ref b }
] => {
35 assert_eq
!("bar", &a
[0..a
.len()]);
36 assert_eq
!("baz", &b
[0..b
.len()]);