Struct re_viewer::external::nohash_hasher::NoHashHasher
pub struct NoHashHasher<T>(pub(crate) u64, pub(crate) bool, pub(crate) PhantomData<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));
Tuple Fields§
§0: u64
§1: bool
§2: PhantomData<T>
Trait Implementations§
§impl<T> Clone for NoHashHasher<T>
impl<T> Clone for NoHashHasher<T>
§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 more§impl<T> Debug for NoHashHasher<T>
impl<T> Debug for NoHashHasher<T>
§impl<T> Default for NoHashHasher<T>
impl<T> Default for NoHashHasher<T>
§fn default() -> NoHashHasher<T>
fn default() -> NoHashHasher<T>
§impl<T> Hasher for NoHashHasher<T>where
T: IsEnabled,
impl<T> Hasher for NoHashHasher<T>where
T: IsEnabled,
§fn write_usize(&mut self, n: usize)
fn write_usize(&mut self, n: usize)
usize
into this hasher.§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>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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> ⓘ
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request