From 30ef5d8c916f83624fc6166b11809e86b1d24a2b Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 11 Sep 2021 20:56:43 -0400 Subject: [PATCH] RBE custom types enum use --- .../custom_types/custom_types_enum_use.rs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 rustbyexample/custom_types/custom_types_enum_use.rs 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!"), + } +}