Why not `impl<'a, T: PartialEq, I: IntoIterator<Item = &'a T>> PartialEq<I> for I`?

It will be convenient to allow comparing two iterators like comparing two slices/arrays/vectors.

Because PartialEq::eq takes shared references as arguments. There is Iterator::eq for convenience Iterator in std::iter - Rust


Also, conflicting implementations. Types like Vec<T> (and similarly, types in 3rd party crates) already have a PartialEq implementation, but also fulfill Self: IntoIterator (as well as &Self: IntoIterator, in case that’s an idea to avoid the shared-reference-arguments issue @sahnehaeubchen mentioned).


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