Skip to content

add remaining from_iter_unique methods#306

Merged
sunshowers merged 1 commit into
mainfrom
sunshowers/spr/add-remaining-from_iter_unique-methods
Jul 20, 2026
Merged

add remaining from_iter_unique methods#306
sunshowers merged 1 commit into
mainfrom
sunshowers/spr/add-remaining-from_iter_unique-methods

Conversation

@sunshowers

Copy link
Copy Markdown
Collaborator

IdOrdMap had a from_iter_unique, but the other maps didn't. Add the remaining impls.

Created using spr 1.3.6-beta.1

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds from_iter_unique constructors to the remaining iddqd map types so callers can build maps from iterators while rejecting (rather than overwriting) the first detected conflict, matching the existing IdOrdMap::from_iter_unique behavior.

Changes:

  • Added from_iter_unique inherent constructors for IdHashMap, BiHashMap, and TriHashMap that return DuplicateItem<T> on the first conflicting insertion.
  • Refactored BiHashMap/TriHashMap insertion to share duplicate-detection logic that can return duplicate indexes for owned-error construction.
  • Added integration tests covering success, empty iterators, and multi-key conflict reporting; updated the changelog.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/iddqd/src/id_hash_map/imp.rs Adds IdHashMap::from_iter_unique implemented via the Entry API to return owned duplicates without T: Clone.
crates/iddqd/src/bi_hash_map/imp.rs Adds BiHashMap::from_iter_unique and refactors insertion to expose duplicate indexes for owned error reporting.
crates/iddqd/src/tri_hash_map/imp.rs Adds TriHashMap::from_iter_unique and refactors insertion similarly to support owned duplicate extraction.
crates/iddqd/tests/integration/id_hash_map.rs Adds tests for IdHashMap::from_iter_unique (empty, success, duplicate error) and extends permutation proptest to cover the constructor.
crates/iddqd/tests/integration/bi_hash_map.rs Adds tests for BiHashMap::from_iter_unique including single- vs multi-item duplicate reporting and extends permutation proptest coverage.
crates/iddqd/tests/integration/tri_hash_map.rs Adds tests for TriHashMap::from_iter_unique including multi-key duplicate reporting and extends permutation proptest coverage.
crates/iddqd/tests/integration/pathological.rs Adds a pathological flip-key test exercising IdHashMap::from_iter_unique behavior under stale-hash conditions.
CHANGELOG.md Documents the new constructors and the “report all distinct conflicts” behavior for multi-key maps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sunshowers
sunshowers merged commit 36d8754 into main Jul 20, 2026
36 checks passed
@sunshowers
sunshowers deleted the sunshowers/spr/add-remaining-from_iter_unique-methods branch July 20, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants