Struct rerun::external::re_viewer_context::external::nohash_hasher::NoHashHasher
source · pub struct NoHashHasher<T>(/* private fields */);
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§
source§impl<T> Clone for NoHashHasher<T>
impl<T> Clone for NoHashHasher<T>
source§fn clone(&self) -> NoHashHasher<T>
fn clone(&self) -> NoHashHasher<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Debug for NoHashHasher<T>
impl<T> Debug for NoHashHasher<T>
source§impl<T> Default for NoHashHasher<T>
impl<T> Default for NoHashHasher<T>
source§fn default() -> NoHashHasher<T>
fn default() -> NoHashHasher<T>
source§impl<T> Hasher for NoHashHasher<T>where
T: IsEnabled,
impl<T> Hasher for NoHashHasher<T>where
T: IsEnabled,
source§fn write_usize(&mut self, n: usize)
fn write_usize(&mut self, n: usize)
usize
into this hasher.source§fn write_isize(&mut self, n: isize)
fn write_isize(&mut self, n: isize)
isize
into this hasher.1.26.0 · source§fn write_u128(&mut self, i: u128)
fn write_u128(&mut self, i: u128)
u128
into this hasher.1.26.0 · source§fn write_i128(&mut self, i: i128)
fn write_i128(&mut self, i: i128)
i128
into this hasher.source§fn write_length_prefix(&mut self, len: usize)
fn write_length_prefix(&mut self, len: usize)
hasher_prefixfree_extras
)impl<T> Copy for NoHashHasher<T>
Auto Trait Implementations§
impl<T> Freeze for NoHashHasher<T>
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§
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.