External Publication
Visit Post

Implement FusedIterator for core::iter::StepBy

Rust Internals [Unofficial] March 12, 2026
Source

mineichen:

Do i miss something?

I don't think so. This impl seems appropriate. The only questions I'd have are:

  • Should the impl be unconditional?
  • Should the correctness of the impl be dependent independent on the correctness of the underlying Iterator's impl?

The answer to both of those is "no" in my opinion. The API docs explain the behavior of StepBy pretty clearly, so answering "yes" to either of the two questions would constitute a change to how StepBy is implemented which in turn would be a breaking change based on its API documentation. There are also already FusedIterator impls in core whose correctness is dependent on the correctness of the underlying Iterator's impl.

Discussion in the ATmosphere

Loading comments...