add remaining from_iter_unique methods#306
Merged
sunshowers merged 1 commit intoJul 20, 2026
Merged
Conversation
Created using spr 1.3.6-beta.1
There was a problem hiding this comment.
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_uniqueinherent constructors forIdHashMap,BiHashMap, andTriHashMapthat returnDuplicateItem<T>on the first conflicting insertion. - Refactored
BiHashMap/TriHashMapinsertion 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
deleted the
sunshowers/spr/add-remaining-from_iter_unique-methods
branch
July 20, 2026 01:38
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.
IdOrdMaphad afrom_iter_unique, but the other maps didn't. Add the remaining impls.