Skip to content

Instantly share code, notes, and snippets.

@ddavison
Created June 18, 2015 20:35
Show Gist options
  • Select an option

  • Save ddavison/6e518bb6d16cb21a50ba to your computer and use it in GitHub Desktop.

Select an option

Save ddavison/6e518bb6d16cb21a50ba to your computer and use it in GitHub Desktop.
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