Skip to content

Conversation

@cuviper
Copy link
Member

@cuviper cuviper commented Aug 28, 2025

This hides the underlying hasher as an implementation detail, so it's no
longer a public dependency. A newtype DefaultHasher is also added here
to wrap the underlying <_ as BuildHasher>::Hasher type.

This is a breaking change now, requiring a semver bump, but it will
allow later changes to the hasher without breaking.


/// Default hasher for [`HashMap`](crate::HashMap) and [`HashSet`](crate::HashSet).
#[cfg(feature = "default-hasher")]
#[derive(Clone)]
Copy link
Member

Choose a reason for hiding this comment

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

Is it really necessary for this to implement Clone? I don't think it every makes sense to clone a Hasher.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's probably not necessary, but FWIW both FoldHasher and std::hash::DefaultHasher do implement Clone.

(std also implements Debug and Default, but FoldHasher does not.)

Copy link
Member Author

Choose a reason for hiding this comment

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

std added Clone in rust-lang/rust#42799, without much discussion.

This hides the underlying hasher as an implementation detail, so it's no
longer a public dependency. A newtype `DefaultHasher` is also added here
to wrap the underlying `<_ as BuildHasher>::Hasher` type.

This is a breaking change now, requiring a semver bump, but it will
allow later changes to the hasher without breaking.
@Amanieu Amanieu added this pull request to the merge queue Aug 29, 2025
Merged via the queue into rust-lang:master with commit 8d4def0 Aug 29, 2025
25 checks passed
@Amanieu
Copy link
Member

Amanieu commented Aug 29, 2025

Hmm apparently updating the version number will cause release-plz to immediately publish a new version of the crate.

@cuviper
Copy link
Member Author

cuviper commented Aug 29, 2025

Sorry, I didn't know it would do that. Maybe this is worth a warning comment in Cargo.toml?

It seems I should have used one of these breaking change indicators in my commit message instead:
https://www.conventionalcommits.org/en/v1.0.0/

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