Another standard library awesomeness:

How to add things to an iterator if you have Some(&things)?

Easy:

`iter.chain(things.cloned().into_iter())`

That's pure awesomeness!

Follow

@musicmatze Nice one!

Even easier, if you have:
let things: Option<T> = Some(T);

and a collection like Vec<T>, HashSet<T> etc. (everything that implements `Extend`):

Just do:
vec.extend(thing);

· · Web · 0 · 0 · 1
Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!