diff --git a/Cargo.toml b/Cargo.toml index ebad45c..522907a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gxhash" authors = ["Olivier Giniaux"] -version = "2.0.0" +version = "2.1.0" edition = "2021" description = "GxHash non-cryptographic algorithm" license = "MIT" diff --git a/src/hasher.rs b/src/hasher.rs index ca1390b..60c4075 100644 --- a/src/hasher.rs +++ b/src/hasher.rs @@ -35,6 +35,18 @@ impl GxHasher { // Use gxhash64 to generate an initial state from a seed GxHasher(unsafe { gxhash(&[], create_seed(seed)) }) } + + /// Finish this hasher and return the hashed value as a 128 bit + /// unsigned integer. + #[inline] + fn finish_u128(&self) -> u128 { + debug_assert!(std::mem::size_of::() >= std::mem::size_of::()); + + unsafe { + let p = &self.0 as *const State as *const u128; + *p + } + } } impl Hasher for GxHasher {