-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose specialized versions of AHasher
through specialized-hashers
feature
#156
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,14 +213,16 @@ impl Hasher for AHasher { | |
} | ||
} | ||
|
||
#[cfg(feature = "specialize")] | ||
pub(crate) struct AHasherU64 { | ||
/// A specialized hasher for only primitives <= 64 bits. | ||
/// | ||
/// Can be built with [`BuildAHasherU64`][crate::BuildAHasherU64] | ||
#[cfg(any(feature = "specialize", feature = "specialized-hashers"))] | ||
pub struct AHasherU64 { | ||
pub(crate) buffer: u64, | ||
pub(crate) pad: u64, | ||
} | ||
|
||
/// A specialized hasher for only primitives under 64 bits. | ||
#[cfg(feature = "specialize")] | ||
#[cfg(any(feature = "specialize", feature = "specialized-hashers"))] | ||
impl Hasher for AHasherU64 { | ||
#[inline] | ||
fn finish(&self) -> u64 { | ||
|
@@ -264,11 +266,13 @@ impl Hasher for AHasherU64 { | |
} | ||
} | ||
|
||
#[cfg(feature = "specialize")] | ||
pub(crate) struct AHasherFixed(pub AHasher); | ||
|
||
/// A specialized hasher for fixed size primitives larger than 64 bits. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't have to be strictly primitives, just fixed in size. So for example a |
||
#[cfg(feature = "specialize")] | ||
/// | ||
/// Can be built with [`BuildAHasherFixed`][crate::BuildAHasherFixed] | ||
#[cfg(any(feature = "specialize", feature = "specialized-hashers"))] | ||
pub struct AHasherFixed(pub(crate) AHasher); | ||
|
||
#[cfg(any(feature = "specialize", feature = "specialized-hashers"))] | ||
impl Hasher for AHasherFixed { | ||
#[inline] | ||
fn finish(&self) -> u64 { | ||
|
@@ -311,12 +315,15 @@ impl Hasher for AHasherFixed { | |
} | ||
} | ||
|
||
#[cfg(feature = "specialize")] | ||
pub(crate) struct AHasherStr(pub AHasher); | ||
/// A specialized hasher for strings. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works for anything that can deref / cast to a |
||
/// | ||
/// Note that other types don't panic because the hash impl for String tacks on an unneeded call. (As does vec) | ||
/// | ||
/// Can be built with [`BuildAHasherStr`][crate::BuildAHasherStr] | ||
#[cfg(any(feature = "specialize", feature = "specialized-hashers"))] | ||
pub struct AHasherStr(pub(crate) AHasher); | ||
|
||
/// A specialized hasher for strings | ||
/// Note that the other types don't panic because the hash impl for String tacks on an unneeded call. (As does vec) | ||
#[cfg(feature = "specialize")] | ||
#[cfg(any(feature = "specialize", feature = "specialized-hashers"))] | ||
impl Hasher for AHasherStr { | ||
#[inline] | ||
fn finish(&self) -> u64 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these are public, they should have a bit more docs. It is probably worth enumerating the types that this works with. (Notably
usize
is not one, as it can technically be 128 bits on some exotic systems)