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

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.