Created
January 2, 2016 22:23
-
-
Save triplepoint/ff2ab81f5f89826d35b7 to your computer and use it in GitHub Desktop.
Short rust pattern-matching demonstration.
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
fn main() { | |
//let some_value: Result<i32, &'static str> = Ok(12); | |
//let some_value: Result<i32, &'static str> = Err("METAL!"); | |
let some_value: Result<i32, &'static str> = Err("There was an error"); | |
match some_value { | |
Ok(value) => println!("got a value: {}", value), | |
Err("METAL!") => println!("a specific metal error occured"), | |
Err(x) => println!("an unknown error occurred: {}", x), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment