Struct NopHasher
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§
Source§impl Hasher for NopHasher
impl Hasher for NopHasher
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_isize(&mut self, i: isize)
fn write_isize(&mut self, i: isize)
Writes a single
isize into this hasher.1.26.0 · Source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
Writes a single
u128 into this hasher.1.26.0 · 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_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 Freeze for NopHasher
impl RefUnwindSafe for NopHasher
impl Send for NopHasher
impl Sync for NopHasher
impl Unpin for NopHasher
impl UnsafeUnpin for NopHasher
impl UnwindSafe for NopHasher
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more