pub struct DeterministicHasher<T: Hasher>(/* private fields */);Expand description
Wrapper around any hasher to make it deterministic.
use core::hash::Hash;
use crc::crc32::Hasher32;
use deterministic_hash::DeterministicHasher;
let mut hasher = DeterministicHasher::new(crc::crc32::Digest::new(crc::crc32::KOOPMAN));
(0x1337 as usize).hash(&mut hasher);
assert_eq!(hasher.as_inner().sum32(), 2482448842);Implementations§
Trait Implementations§
Source§impl<T: Clone + Hasher> Clone for DeterministicHasher<T>
impl<T: Clone + Hasher> Clone for DeterministicHasher<T>
Source§fn clone(&self) -> DeterministicHasher<T>
fn clone(&self) -> DeterministicHasher<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Default + Hasher> Default for DeterministicHasher<T>
impl<T: Default + Hasher> Default for DeterministicHasher<T>
Source§fn default() -> DeterministicHasher<T>
fn default() -> DeterministicHasher<T>
Returns the “default value” for a type. Read more
Source§impl<T: Hasher> Hasher for DeterministicHasher<T>
Implementation of hasher that forces all bytes written to be platform agnostic.
impl<T: Hasher> Hasher for DeterministicHasher<T>
Implementation of hasher that forces all bytes written to be platform agnostic.
Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
Writes a single
u128 into this hasher.Source§fn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
Writes a single
usize into this hasher.Source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
Writes a single
i128 into this hasher.Source§fn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
Writes a single
isize into this hasher.Source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
🔬This is a nightly-only experimental API. (
hasher_prefixfree_extras)Writes a length prefix into this hasher, as part of being prefix-free. Read more
Auto Trait Implementations§
impl<T> Freeze for DeterministicHasher<T>where
T: Freeze,
impl<T> RefUnwindSafe for DeterministicHasher<T>where
T: RefUnwindSafe,
impl<T> Send for DeterministicHasher<T>where
T: Send,
impl<T> Sync for DeterministicHasher<T>where
T: Sync,
impl<T> Unpin for DeterministicHasher<T>where
T: Unpin,
impl<T> UnwindSafe for DeterministicHasher<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more