Created
April 4, 2014 18:31
-
-
Save nebuta/9980545 to your computer and use it in GitHub Desktop.
Rust stdin splitting and conversion to int
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
// 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