Use flatten to iterate over only Some values if you have a collection of Options.
1
2
3
4
5
6
let nums = vec![None, Some(2), None, Some(3), None];
let mut iter = nums.into_iter().flatten();
assert_eq!(iter.next(), Some(2));
assert_eq!(iter.next(), Some(3));