I have a vector Optionand I want to filter only Somes. I use filter_mapwith id:
let v = vec![Some(1), None, Some(2)];
for i in v.into_iter().filter_map(|o| o) {
println!("{}", i);
}
Is there a built-in function that allows you to write something like filter_map(identity)?
source
share