RBE custom types enum use
This commit is contained in:
parent
5d0811636f
commit
30ef5d8c91
29
rustbyexample/custom_types/custom_types_enum_use.rs
Normal file
29
rustbyexample/custom_types/custom_types_enum_use.rs
Normal file
@ -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!"),
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user