]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/enum-discr.rs
rollup merge of #18968: danluu/guide_play
[rust.git] / src / test / run-pass / enum-discr.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.
4 //
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.
10
11 enum Animal {
12     Cat = 0,
13     Dog = 1,
14     Horse = 2,
15     Snake = 3,
16 }
17
18 enum Hero {
19     Batman = -1,
20     Superman = -2,
21     Ironman = -3,
22     Spiderman = -4
23 }
24
25 pub fn main() {
26     let pet: Animal = Animal::Snake;
27     let hero: Hero = Hero::Superman;
28     assert!(pet as uint == 3);
29     assert!(hero as int == -2);
30 }