Struct nohash_hasher::NoHashHasher
source · [−]pub struct NoHashHasher<T>(_, _, _);
Expand description
For an enabled type T
, a NoHashHasher<T>
implements std::hash::Hasher
and
uses the value set by one of the write_{u8, u16, u32, u64, usize, i8, i16, i32, i64, isize}
methods as its hash output.
NoHashHasher
does not implement any hashing algorithm and can only be used
with types which can be mapped directly to a numeric value. Out of the box
NoHashHasher
is enabled for u8
, u16
, u32
, u64
, usize
, i8
, i16
,
i32
, i64
, and isize
. Types that should be used with NoHashHasher
need
to implement IsEnabled
and by doing so assert that their Hash
impl invokes
only one of the Hasher::write_{u8, u16, u32, u64, usize, i8, i16, i32, i64, isize}
methods exactly once.
Examples
See also BuildNoHashHasher
, IntMap
and IntSet
for some easier
usage examples. See IsEnabled
for use with custom types.
use nohash_hasher::NoHashHasher;
use std::{collections::HashMap, hash::BuildHasherDefault};
let mut m: HashMap::<u8, char, BuildHasherDefault<NoHashHasher<u8>>> =
HashMap::with_capacity_and_hasher(2, BuildHasherDefault::default());
m.insert(0, 'a');
m.insert(1, 'b');
assert_eq!(Some(&'a'), m.get(&0));
assert_eq!(Some(&'b'), m.get(&1));
Trait Implementations
sourceimpl<T> Clone for NoHashHasher<T>
impl<T> Clone for NoHashHasher<T>
sourceimpl<T> Debug for NoHashHasher<T>
impl<T> Debug for NoHashHasher<T>
sourceimpl<T> Default for NoHashHasher<T>
impl<T> Default for NoHashHasher<T>
sourceimpl<T: IsEnabled> Hasher for NoHashHasher<T>
impl<T: IsEnabled> Hasher for NoHashHasher<T>
sourcefn write_usize(&mut self, n: usize)
fn write_usize(&mut self, n: usize)
Writes a single usize
into this hasher.
sourcefn write_isize(&mut self, n: isize)
fn write_isize(&mut self, n: 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.
impl<T> Copy for NoHashHasher<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for NoHashHasher<T> where
T: RefUnwindSafe,
impl<T> Send for NoHashHasher<T> where
T: Send,
impl<T> Sync for NoHashHasher<T> where
T: Sync,
impl<T> Unpin for NoHashHasher<T> where
T: Unpin,
impl<T> UnwindSafe for NoHashHasher<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more