In your case since you are not doing any mapping, I would suggest using flatten
ing instead of filter_map
ing.Which in my opinion is much clearer and more self explanatory.
let optvec = vec![Some(1), None, Some(4), None]; let filtered: Vec<i32> = optvec.iter().flatten().cloned().collect(); assert_eq!(filtered, &[1, 4]);