]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/enum-discr.rs
1ff6370136076e76e800ce68c773a6f9ebdabc95
[rustc.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
12 enum Animal {
13 Cat = 0,
14 Dog = 1,
15 Horse = 2,
16 Snake = 3,
17 }
18
19 enum Hero {
20 Batman = -1,
21 Superman = -2,
22 Ironman = -3,
23 Spiderman = -4
24 }
25
26 pub fn main() {
27 let pet: Animal = Animal::Snake;
28 let hero: Hero = Hero::Superman;
29 assert!(pet as usize == 3);
30 assert!(hero as isize == -2);
31 }