One thing I am missing more and more in the Rust ecosystem is a set of iterators that can handle
Option elements. Or rather, what I need is to make decisions based on the Some/Ok-ness of those elements. For example, stop processing when an element yields a
None or an
Err, and then return the error.
As far as I know, currently often the best way to handle situations like this is to largely avoid the Iterator methods (e.g.
filter) altogether in favor of for-loops. The problems with this are
- that it is verbose to do (it’s not just the for-loop but also the error handling code) and
- that it often requires an intermediate allocation.
Does anyone know of a crate that can help with this e.g. by reducing boilerplate and preventing the allocation?