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

**URL:** <https://internals.rust-lang.org/t/why-not-impl-a-t-partialeq-i-intoiterator-item-a-t-partialeq-i-for-i/19418>\
**Category:** libs\
**Created:** [August 26, 2023, 2:34pm UTC](https://internals.rust-lang.org/t/why-not-impl-a-t-partialeq-i-intoiterator-item-a-t-partialeq-i-for-i/19418 "2023-08-26T14:34:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stackinspector](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/stackinspector/32/9487_2.png) [@stackinspector](https://internals.rust-lang.org/u/stackinspector)\
**Post date:** [August 26, 2023, 2:34pm UTC](https://internals.rust-lang.org/t/why-not-impl-a-t-partialeq-i-intoiterator-item-a-t-partialeq-i-for-i/19418/1 "2023-08-26T14:34:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sahnehaeubchen](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/sahnehaeubchen/32/9709_2.png) [@sahnehaeubchen](https://internals.rust-lang.org/u/sahnehaeubchen)\
**Post date:** [August 26, 2023, 2:38pm UTC](https://internals.rust-lang.org/t/why-not-impl-a-t-partialeq-i-intoiterator-item-a-t-partialeq-i-for-i/19418/2 "2023-08-26T14:38:33Z")

</div>

Because `PartialEq::eq` takes shared references as arguments. There is `Iterator::eq` for convenience [Iterator in std::iter - Rust](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.eq)

---

<div class="post-metadata">

**Author:** ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Post date:** [August 26, 2023, 3:00pm UTC](https://internals.rust-lang.org/t/why-not-impl-a-t-partialeq-i-intoiterator-item-a-t-partialeq-i-for-i/19418/3 "2023-08-26T15:00:49Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [November 24, 2023, 3:01pm UTC](https://internals.rust-lang.org/t/why-not-impl-a-t-partialeq-i-intoiterator-item-a-t-partialeq-i-for-i/19418/4 "2023-11-24T15:01:45Z")

</div>

Closed on November 24, 2023, 3:01pm UTC

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