Struct nohash_hasher::NoHashHasher [−][src]
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
impl<T> Clone for NoHashHasher<T>[src]
fn clone(&self) -> Self[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<T> Copy for NoHashHasher<T>[src]
impl<T> Debug for NoHashHasher<T>[src]
impl<T> Default for NoHashHasher<T>[src]
impl<T: IsEnabled> Hasher for NoHashHasher<T>[src]
fn write(&mut self, _: &[u8])[src]
fn write_u8(&mut self, n: u8)[src]
fn write_u16(&mut self, n: u16)[src]
fn write_u32(&mut self, n: u32)[src]
fn write_u64(&mut self, n: u64)[src]
fn write_usize(&mut self, n: usize)[src]
fn write_i8(&mut self, n: i8)[src]
fn write_i16(&mut self, n: i16)[src]
fn write_i32(&mut self, n: i32)[src]
fn write_i64(&mut self, n: i64)[src]
fn write_isize(&mut self, n: isize)[src]
fn finish(&self) -> u64[src]
pub fn write_u128(&mut self, i: u128)1.26.0[src]
pub fn write_i128(&mut self, i: i128)1.26.0[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for NoHashHasher<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for NoHashHasher<T> where
T: Send,
T: Send,
impl<T> Sync for NoHashHasher<T> where
T: Sync,
T: Sync,
impl<T> Unpin for NoHashHasher<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for NoHashHasher<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,