Skip to content

Instantly share code, notes, and snippets.

@sboesen
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save sboesen/11408503 to your computer and use it in GitHub Desktop.

Select an option

Save sboesen/11408503 to your computer and use it in GitHub Desktop.
use std::io::BufferedReader;
use std::io;
use rand::Rng;
fn main() {
println!("INPUT:");
let mut reader = BufferedReader::new(io::stdin());
let input = reader.read_line().unwrap();
let num = from_str::<int>(input.slice_to(input.len() -1));
match num {
Some(number_string) => println!("You typed: {:s}", number_string.to_str()),
None => println!("Hey, put in a number!")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment