RBE custom types enum c-like
This commit is contained in:
parent
30ef5d8c91
commit
cbcf9ce5fc
21
rustbyexample/custom_types/custom_types_enum_c_like.rs
Normal file
21
rustbyexample/custom_types/custom_types_enum_c_like.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
enum Number {
|
||||||
|
Zero,
|
||||||
|
One,
|
||||||
|
Two,
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Color {
|
||||||
|
Red = 0xff0000,
|
||||||
|
Green = 0x00ff00,
|
||||||
|
Blue = 0x0000ff,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
println!("zero is {}", Number::Zero as i32);
|
||||||
|
println!("one is {}", Number::One as i32);
|
||||||
|
|
||||||
|
println!("roses are #{:06x}", Color::Red as i32);
|
||||||
|
println!("violets are #{:06x}", Color::Blue as i32);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user