Skip to content

Conversation

@Mandalorian7773
Copy link

@Mandalorian7773 Mandalorian7773 commented Dec 18, 2025

Summary

This PR fixes asymmetric equality between arrays and Vecs by adding a missing
PartialEq<Vec<U>> for [T; N] implementation.

Previously, comparisons like Vec<T> == [T; N] were supported, but the reverse
[T; N] == Vec<T> failed due to the absence of a corresponding PartialEq impl.
This PR completes the symmetry by forwarding the comparison to existing slice
equality.

Details

  • Adds PartialEq<Vec<U>> for [T; N] in the array equality implementation.
  • The comparison is implemented by converting both sides to slices and reusing
    existing slice equality logic.
  • No new behavior is introduced beyond completing the missing symmetric case.
  • No allocations or unsafe code are involved.

Fixes #149017

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 18, 2025

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot

This comment has been minimized.

This fixes asymmetric equality between arrays and Vecs.
Previously `Vec<T> == [T; N]` was supported but `[T; N] == Vec<T]`
failed due to a missing impl. The new implementation forwards to
slice equality and adds tests to cover the behavior.
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 }
 
-
 // NOTE: some less important impls are omitted to reduce code bloat
 // __impl_slice_eq2! { [A; $N], &'b [B; $N] }
 // __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }
fmt: checked 6606 files
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Build completed unsuccessfully in 0:00:46
  local time: Thu Dec 18 21:31:05 UTC 2025
  network time: Thu, 18 Dec 2025 21:31:05 GMT

@theemathas
Copy link
Contributor

This is a duplicate of #149045

@Kivooeo
Copy link
Member

Kivooeo commented Dec 19, 2025

closing as duplicate

@Kivooeo Kivooeo closed this Dec 19, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing impl PartialEq<Vec<T>> for [T; N]

6 participants