diff --git a/rustbyexample/custom_types/custom_types_enum_use.rs b/rustbyexample/custom_types/custom_types_enum_use.rs new file mode 100644 index 0000000..86f7915 --- /dev/null +++ b/rustbyexample/custom_types/custom_types_enum_use.rs @@ -0,0 +1,29 @@ +#![allow(dead_code)] + +enum Status { + Rich, + Poor, +} + +enum Work { + Civilian, + Soldier, +} + +fn main() { + use crate::Status::{Poor, Rich}; + use crate::Work::*; + + let status = Poor; + let work = Civilian; + + match status { + Rich => println!("The rich have lots of money!"), + Poor => println!("The poor have no money..."), + } + + match work { + Civilian => println!("Civilians work!"), + Soldier => println!("Soldiers fight!"), + } +}