From cbcf9ce5fc9e74762f772523771700fa2a6a1fac Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Sep 2021 20:59:39 -0400 Subject: [PATCH] RBE custom types enum c-like --- .../custom_types/custom_types_enum_c_like.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 rustbyexample/custom_types/custom_types_enum_c_like.rs diff --git a/rustbyexample/custom_types/custom_types_enum_c_like.rs b/rustbyexample/custom_types/custom_types_enum_c_like.rs new file mode 100644 index 0000000..1057259 --- /dev/null +++ b/rustbyexample/custom_types/custom_types_enum_c_like.rs @@ -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); +}