Option<V<T>>.iter() when V<T> has .iter()

Let V be some collection class, say, HashMap, HashSet, Vec, ...

Consider:

coll: Option<V<T>>;

Is there a simple way to do a "coll.iter" where

Some(lst) => iter over lst.iter()
None => some iter that is empty

coll.iter().flatten()

3 Likes

coll.iter().flatten()

1 Like