Last change
on this file since 878b1385 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
|
Rev | Line | |
---|
[1725989] | 1 | use std::mem; |
---|
| 2 | |
---|
| 3 | #[derive(Debug, Clone, Copy)] |
---|
| 4 | enum Week { Mon, Tues, Wed = 2, Thu = 10, Fri, Sat = 5, Sun } |
---|
| 5 | |
---|
| 6 | fn 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.