source: doc/theses/jiada_liang_MMath/test2.rs @ 3f37f5b

Last change on this file since 3f37f5b was 1725989, checked in by Peter A. Buhr <pabuhr@…>, 5 months ago

add enumeration test programs for different programming languages

  • Property mode set to 100644
File size: 519 bytes
Line 
1use std::mem;
2
3#[derive(Debug, Clone, Copy)]
4enum Week { Mon, Tues, Wed = 2, Thu = 10, Fri, Sat = 5, Sun }
5
6fn main() {
7        let mut week: Week = Week::Mon;
8        println!( "{:?} {:?}", week as isize, Week::Fri as isize );
9        if mem::discriminant(&week) == mem::discriminant(&Week::Mon) {
10                println!( "{:?}", week );
11        }
12        if week as isize == Week::Mon as isize {
13                println!( "{:?}", week );
14        }
15        for n in Week::Mon as isize .. Week::Fri as isize {
16                println!( "{:?}", n );
17        }
18}
19
20// Local Variables: //
21// tab-width: 4 //
22// End: //
Note: See TracBrowser for help on using the repository browser.