Why do I need to collect into a vector when using `flat_map`?
问题 I'm working on Project Euler 96 to teach myself Rust. I've written this code to read in the file and convert it into a vector of integers (Playground). let file = File::open(&args[1]).expect("Sudoku file not found"); let reader = BufReader::new(file); let x = reader .lines() .map(|x| x.unwrap()) .filter(|x| !x.starts_with("Grid")) .flat_map(|s| s.chars().collect::<Vec<_>>()) // <-- collect here! .map(|x| x.to_digit(10).unwrap()) .collect::<Vec<_>>(); This all works fine but I'm puzzled why I