]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs-enums/issue-1701.rs
Rollup merge of #89468 - FabianWolff:issue-89358, r=jackh726
[rust.git] / src / test / ui / structs-enums / issue-1701.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(non_camel_case_types)]
4
5
6 enum pattern { tabby, tortoiseshell, calico }
7 enum breed { beagle, rottweiler, pug }
8 type name = String;
9 enum ear_kind { lop, upright }
10 enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger }
11
12 fn noise(a: animal) -> Option<String> {
13     match a {
14       animal::cat(..)    => { Some("meow".to_string()) }
15       animal::dog(..)    => { Some("woof".to_string()) }
16       animal::rabbit(..) => { None }
17       animal::tiger  => { Some("roar".to_string()) }
18     }
19 }
20
21 pub fn main() {
22     assert_eq!(noise(animal::cat(pattern::tabby)), Some("meow".to_string()));
23     assert_eq!(noise(animal::dog(breed::pug)), Some("woof".to_string()));
24     assert_eq!(noise(animal::rabbit("Hilbert".to_string(), ear_kind::upright)), None);
25     assert_eq!(noise(animal::tiger), Some("roar".to_string()));
26 }