iter_enumeration
This crate provides utility to unify Iterator
s over the same type.
Dealing with Iterator
types originating from different parts of the code,
such as separate branches of a match
, can be a bit cumbersome.
A similar problem arises with an iterator over iterators.
Alternative solutions to this problem:
One can collect
the iterator, do something with Box<dyn Iterator>
,
or redesign altogether.
However, this crate allows you to do this:
Example
use ;
// start with any iterator
let it = 0..10;
// have some branching code
let it = if true else ;
// continue with the unified iterator enum type
let it = it.inspect;
// or have more branches, up to 6, currently
use IntoIterEnum3;
let it = match 42 ;
Note that there is also iter-enum, which provides a similar solution but differs from what I want: You either have to define the enum yourself or use auto_enum, which uses proc-macros.