Use map to apply a function or closure to each iterator item, or to transform a present Option or Result value. Iterator map returns another iterator and evaluates lazily; collect forces evaluation and may need a target type annotation. section 3.2.5 section 10.3
let arr = [1, 2, 3, 4];
println!("{:?}", arr);
let vec: Vec<_> = arr.iter().map(|v| v.to_string()).collect();
println!("{:?}", vec);
This example converts array elements to strings, then collects the transformed iterator into a vector. section 3.2.5
Transforming parsed values
Parsing strings with map produces Result values, so partition can separate successful parses from errors without discarding either. By contrast, flat_map flattens each Result into an iterator: an Ok contributes its value, while an Err contributes nothing. section 3.2.5 section 3.2.5
For Option and Result, map transforms the contained value only when it is present or successful; None and Err pass through unchanged. Prefer this to unwrap when transforming a value without needing to handle failure by panicking. section 10.3 section 10.10



















