collect() consumes an iterator and builds a collection, usually a Vec. It also forces lazy iterator operations, such as map(), to run. Specify the target type when the compiler cannot infer it. section 3.2.5
let arr = [1, 2, 3, 4];
println!("{:?}", arr);
let vec: Vec<_> = arr.iter().map(|v| v.to_string()).collect();
println!("{:?}", vec);
Map an array’s values to strings, then collect them into a Vec. section 3.2.5
Choose a different collection
collect() can build a LinkedList too. Here, flat_map() turns each parse result into an iterator before collecting; failed parses are discarded, so use an approach that preserves errors when they matter. section 3.2.5


