Prepare publishing of HashSortedMap#126
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Prepares the hash-sorted-map crate for publishing by improving public-facing documentation and making hashing customizable via a new SortingHash abstraction (allowing keys that don’t implement std::hash::Hash when a custom hasher is supplied).
Changes:
- Added crate-level/module documentation and enabled
#![warn(missing_docs)]for the crate. - Introduced the
SortingHashtrait (with a blanket impl forBuildHasher) and refactoredHashSortedMapAPIs to use it. - Publishing polish: README updates, added MIT LICENSE, and set the benchmarks crate to
publish = false.
Show a summary per file
| File | Description |
|---|---|
| crates/hash-sorted-map/src/lib.rs | Adds crate-level docs and re-exports SortingHash; enables missing-docs warnings. |
| crates/hash-sorted-map/src/hash_sorted_map.rs | Introduces SortingHash + switches internal hashing to 32-bit; updates API bounds/docs; adds a test for non-Hash keys. |
| crates/hash-sorted-map/README.md | Updates public README to describe the new hashing model. |
| crates/hash-sorted-map/LICENSE | Adds MIT license text for publishing. |
| crates/hash-sorted-map/benchmarks/Cargo.toml | Marks benchmarks crate as non-publishable. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
crates/hash-sorted-map/src/hash_sorted_map.rs:113
n_bitsis derived from the requested capacity and can exceed 32 on 64-bit targets. Since hashes are now 32-bit (u32),group_index()does32 - n_bits, which will underflow and later shifts will panic/misbehave ifn_bits > 32. Consider asserting the invariant at construction time.
let adjusted = (capacity as f64 / group_ops::MAX_FILL).ceil() as usize;
let min_groups = (adjusted.div_ceil(GROUP_SIZE)).max(1).next_power_of_two();
let n_bits = min_groups.trailing_zeros().max(1);
let (groups, num_groups) = Self::alloc_groups(n_bits);
- Files reviewed: 5/5 changed files
- Comments generated: 3
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The hasher determines a HashSortedMap's iteration order, so there is no meaningful default hasher for a sort-by-hash map (RandomState gives a different, per-process order, defeating the purpose). Remove the `S = RandomState` default type parameter and stop hardcoding RandomState in new()/with_capacity()/Default; those now construct `S::default()`, so a map with a custom default-constructible SortingHash works via the type's own constructors. Any BuildHasher (incl. RandomState) is still usable by naming it explicitly through the blanket SortingHash impl. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gorzell
approved these changes
Jun 15, 2026
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.
No description provided.