I\'m writing on STDIN a string of numbers (e.g 4 10 30 232312) and I want to read that and convert to an array (or a vector) of integers, but I can\'t find the
4 10 30 232312
On Rust 1.5.x, a working solution is:
fn main() { let mut numbers = String::new(); io::stdin() .read_line(&mut numbers) .ok() .expect("read error"); let numbers: Vec = numbers .split_whitespace() .map(|s| s.parse().expect("parse error")) .collect(); for num in numbers { println!("{}", num); } }