pub struct NopHasher { /* private fields */ }
Expand description
An implementation of Hasher
hasher which only accepts values with a size
of 8 bytes or an integral value fitting into 8 bytes.
Panics
Panics if values with a size greater than 8 bytes are passed in.
Examples
Usage:
use std::hash::{Hash, Hasher};
use astral::util::hash::NopHasher;
let mut hasher = NopHasher::default();
1234_5678_u32.hash(&mut hasher);
assert_eq!(hasher.finish(), 1234_5678);
Slices and arrays cannot be hashed directly, since their len is also hashed.
Hash::hash_slice
may be used instead:
use std::hash::{Hash, Hasher};
use astral::util::hash::NopHasher;
let mut hasher = NopHasher::default();
let arr = [0x12_u8, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0];
Hash::hash_slice(&arr, &mut hasher);
assert_eq!(hasher.finish(), 0x1234_5678_9ABC_DEF0_u64.to_be());
Trait Implementations
sourceimpl Hasher for NopHasher
impl Hasher for NopHasher
sourcefn write_usize(&mut self, i: usize)
fn write_usize(&mut self, i: usize)
Writes a single
usize
into this hasher.sourcefn write_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
Writes a single
isize
into this hasher.1.26.0 · sourcefn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
Writes a single
u128
into this hasher.1.26.0 · sourcefn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
Writes a single
i128
into this hasher.sourcefn 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 RefUnwindSafe for NopHasher
impl Send for NopHasher
impl Sync for NopHasher
impl Unpin for NopHasher
impl UnwindSafe for NopHasher
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more