Skip to content

Instantly share code, notes, and snippets.

@nebuta
Created April 4, 2014 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nebuta/9980545 to your computer and use it in GitHub Desktop.
Save nebuta/9980545 to your computer and use it in GitHub Desktop.
Rust stdin splitting and conversion to int
// Compiles on rustc 0.11-pre-nightly (540c2a2 2014-04-04 01:01:51 -0700)
use std::io::BufferedReader;
use std::io::stdin;
fn main(){
let mut stdin = BufferedReader::new(stdin());
let l = stdin.read_line();
match l {
Ok(ll) => {
let ss: ~[Option<int>] = ll.trim().split(' ').map(|a|from_str(a)).collect();
println!("{}",ss);
},
Err(_) => ()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment