Upcast to impl Iterator

Note that this problem -- and solution -- with Either is the same as the problem with Chain, which is why for_each is faster than for for Chain.

This is sadly not yet possible on stable, as doing so requires mentioning an unstable trait.

But yes, overriding try_fold will automatically improve all* of those. fold doesn't help for short-circuiting things like any/all/find.

*well, except nth, right now, because it doesn't require Sized like the others and thus needs specialization to do in terms of try_fold

1 Like