rust/src/test/run-pass/vec-tail-matching.rs
Chris Morgan e2807a4565 Replace unreachable() calls with unreachable!().
This is the second of two parts of #8991, now possible as a new snapshot
has been made. (The first part implemented the unreachable!() macro; it
was #8992, 6b7b8f2682.)

``std::util::unreachable()`` is removed summarily; any code which used
it should now use the ``unreachable!()`` macro.

Closes #9312.

Closes #8991.
2013-09-19 15:04:03 +10:00

36 lines
896 B
Rust

struct Foo {
string: ~str
}
pub fn main() {
let x = ~[
Foo { string: ~"foo" },
Foo { string: ~"bar" },
Foo { string: ~"baz" }
];
match x {
[ref first, ..tail] => {
assert!(first.string == ~"foo");
assert_eq!(tail.len(), 2);
assert!(tail[0].string == ~"bar");
assert!(tail[1].string == ~"baz");
match tail {
[Foo { _ }, _, Foo { _ }, .. _tail] => {
unreachable!();
}
[Foo { string: ref a }, Foo { string: ref b }] => {
assert_eq!("bar", a.slice(0, a.len()));
assert_eq!("baz", b.slice(0, b.len()));
}
_ => {
unreachable!();
}
}
}
_ => {
unreachable!();
}
}
}