Created
June 18, 2015 20:35
-
-
Save ddavison/6e518bb6d16cb21a50ba to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| use std::io; | |
| fn main() { | |
| println!("What's your name?"); | |
| let mut name = String::new(); | |
| io::stdin().read_line(&mut name) | |
| .ok() | |
| .expect("Failed to read line"); | |
| match name { | |
| "Alice" => greet(name), | |
| _ => { println!("Not allowed.. was {}", name) } | |
| } | |
| } | |
| fn greet(name: String) { | |
| println!("Your name is: {}", name); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment