Last active
June 17, 2016 22:21
-
-
Save Jahangir-Sh/1174c8de0be46ea87915db615c843f45 to your computer and use it in GitHub Desktop.
enum matching
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[allow(dead_code)] | |
enum Eden { | |
Coordinator, | |
Doctor, | |
Engineer, | |
Cybernetic { | |
name: &'static str | |
} | |
} | |
fn stuff(p: Eden){ | |
match p { | |
Eden::Coordinator => println!("C"), | |
Eden::Doctor => println!("D"), | |
Eden::Engineer => println!("E"), | |
Eden::Cyberneticist { name } => println!("I -> {}", name) | |
} | |
} | |
fn main() { | |
let cyberneticist = Eden::Cyberneticist {name: "Herald"}; | |
stuff(cyberneticist); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment