Struct nohash::NoHashHasher[][src]

pub struct NoHashHasher<T>(_, _, _);

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::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]

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]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.