rust/src/test/run-pass/issue-1701.rs

21 lines
607 B
Rust
Raw Normal View History

enum pattern { tabby, tortoiseshell, calico }
enum breed { beagle, rottweiler, pug }
type name = ~str;
enum ear_kind { lop, upright }
enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger }
fn noise(a: animal) -> option<~str> {
alt a {
2012-08-03 21:59:04 -05:00
cat(*) => { some(~"meow") }
dog(*) => { some(~"woof") }
rabbit(*) => { none }
tiger(*) => { some(~"roar") }
}
}
fn main() {
assert noise(cat(tabby)) == some(~"meow");
assert noise(dog(pug)) == some(~"woof");
assert noise(rabbit(~"Hilbert", upright)) == none;
assert noise(tiger) == some(~"roar");
}