Repository navigation
feat(ts): compare std sequences of unlike items, and VecDeque against any - #313
Merged
Merged
Conversation
Quest-Claim: 8377302edac9656b
… any Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…two of one type Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
October 30, 2026 23:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes quest/m3/ts-eq-unlike.md.
Problem
==,!=, andnext_if_eqof std sequences were refused (unsupported call) unless both sides held items that compare alike: aVec<Left>against a&[Right]byLeft: PartialEq<Right>, and everyVecDequecomparison, against aVec, slice, array, or anotherVecDeque. The reject fixture'speeked_dequeandunlike_elementsshowed it.Approach
PartialEqimpls: slices, arrays,Vec, andVecDeque(againstVec,&[U],&mut [U],[U; N],&[U; N],&mut [U; N], and itself) all compare lengths, then each pair in order by the items'!=, and their ownneis!eq.Option,Result,Box, and tuples only compare one type with itself.Cow<[T]>is refused as a type anyway.rt.eqSeq(eq)compares any two sequence forms: JS arrays, bytes in any form, and a deque's ring, read through its head.seq_eqlowers a sequence pair the key mapping doesn't already handle: unlike items, items that are no key, or aVecDequeon either side.item_eqcompares each pair by!<T as PartialEq<U>>::newhere the crate overridesne, and byeqotherwise. A[u8; N]item is lent as thert.ByteSliceits&[u8; N]is.Leftagainst&RightusesLeft: PartialEq<&Right>, and a crate's own impl of two references is called as is.alikeno longer treats a crate's type and a reference to it as two values of one type.next_if_eqsharesimpl_eqwith the item path, so its lending code is in one place.collections::unlike_eqsdifferential case. It covers unequal lengths, empty sides, items whereeqandnedisagree (logging every call, which shows which one std calls and where it stops), the reverse impl with the defaultne, a deque wrapped around its buffer against each sequence form, byte deques,Vec<u8>against a crate type, nested sequences, reference-specific impls, andnext_if_eqmatching and missing.caller.tsadds every disagreement position over inputs of length 0, 1, 2, 4, and 9. The reject fixture drops both roots, which now translate.eqinstead of an overriddenneproduced 871 differential differences, and reading a deque without its head produced 387.Impact
rt.eqSeq. No breaking change.Alternatives
eqSliceitself to read every form. This addsinstanceofchecks to every key comparison, so it stays as the fast path for arrays.Follow-ups
nethe crate overrides are still refused, in slices,VecDeques, and through tuples andArcs.item_eq's!nepath is the likely fix.Review
Codex (
quest review), gpt-6.1-sol, medium effort. Session01a18f1d, latest round 4 on headed76a2cedb67c5d6bdf91524fb06f4a7c84d309c: no findings.Vec<Left> == Vec<&Right>peeled both references and resolved the wrong impl. Fixed: references are peeled only in pairs. Two findings indrop.rsandmir/call.rswere refuted: those files came from feat(ts): drop values inside std's iterators and formatting where std's do #307 on origin/main, which this branch has since merged, andgit diff origin/mainon them is empty.impl PartialEq<&Right> for &Leftwas peeled past. Fixed: peeling only happens where std's forwarding impl resolves, with differential coverage (Odd).(written by Claude Opus 5.5)
🤖 Generated with Claude Code