History: Why IteratorExt is removed?

I notice that tool trait like tokio_stream::Stream often designed into two parts: the Stream one for implementing, and the StreamExt for providing features. So i wonder why core::iter::Iterator is not designed that way.

After searching, i found out Iterator does designed in two parts in the past, but was removed at #23300.

Is there anything explanations about why IteratorExt is merged into Iterator?

There's a clue in RFC 503:

// The `Iterator*Ext` traits can be removed if generalized where clauses for
// methods are implemented, and they are currently included to represent the
// functionality provided today. The various traits other than `Iterator`, such
// as `DoubleEndedIterator` and `ExactSizeIterator` are provided in order to
// ensure that the methods are available like the `Iterator` methods.

And more discussion here.

TL;DR: It existed to make Iterator object-safe before the where Self: Sized exception existed.

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.