Should fused fallible iterators/lenders be fused on errors, too?
⚓ Rust 📅 2026-01-31 👤 surdeus 👁️ 9This is a very general design question. "Fused", in Rust, for iterators, means that they are idempotent on None: once they return none, they always return None.
Now, fallible iterators (like in the fallible-iterator crate, or in the fallible version of lenders return a Result. Certainly we want such iterators to be idempotent on Ok(None). That's what fallible-iterator does in the fused case.
But while working on fallible lenders it came to my mind that, maybe, it would be sensible to be idempotent on a returned error, too. In general, the approach to after-error method call is "unpredictable" (as after None in an iterator). So it would make sense that fusing a fallible iterator or lender would make the returned error idempotent, too.
That has a cost, of course, as it implies additional state, tests, etc. And maybe it doesn't make much sense because usually an error unleashes some kind of recovery path that will not insist on calling next.
But I'd love to hear what people think of the issue.
3 posts - 2 participants
🏷️ Rust_feed