pub struct How<T: ?Sized, H = DefaultHasher, S = Cell<u64>> { /* private fields */ }
Expand description
A wrapper for storing hash results to avoid running costly hash functions multiple times without modifying the value
§Examples
let mut x = How::new_default("foo".to_owned());
assert!(! How::is_hashed(&x));
HashSet::new().insert(&x);
assert!(How::is_hashed(&x));
How::make_mut(&mut x).push('!');
assert!(! How::is_hashed(&x));
assert_eq!(*x, "foo!");
Due to the inability of the stored hashcode to replicate the action of T::hash,
it is not possible to implement Borrow<T>
Implementations§
Source§impl<T> How<T>
impl<T> How<T>
Sourcepub fn new_default(value: T) -> Self
pub fn new_default(value: T) -> Self
new, but use DefaultHasher
Source§impl<T, H, S> How<T, H, S>
impl<T, H, S> How<T, H, S>
Sourcepub fn into_inner(this: Self) -> T
pub fn into_inner(this: Self) -> T
Consume self
into wrapped value
Source§impl<T: ?Sized, H, S: HashStorer> How<T, H, S>
impl<T: ?Sized, H, S: HashStorer> How<T, H, S>
Trait Implementations§
Source§impl<T, Q, H, S> BorrowMut<Borrowed<Q, H, S>> for How<T, H, S>
impl<T, Q, H, S> BorrowMut<Borrowed<Q, H, S>> for How<T, H, S>
Source§fn borrow_mut(&mut self) -> &mut Borrowed<Q, H, S>
fn borrow_mut(&mut self) -> &mut Borrowed<Q, H, S>
Mutably borrows from an owned value. Read more
Source§impl<T: ?Sized + Ord, H, S: HashStorer> Ord for How<T, H, S>
impl<T: ?Sized + Ord, H, S: HashStorer> Ord for How<T, H, S>
Source§impl<T: ?Sized + PartialOrd, H, S> PartialOrd<T> for How<T, H, S>
impl<T: ?Sized + PartialOrd, H, S> PartialOrd<T> for How<T, H, S>
Source§impl<T: ?Sized + PartialOrd, H, S: HashStorer> PartialOrd for How<T, H, S>
impl<T: ?Sized + PartialOrd, H, S: HashStorer> PartialOrd for How<T, H, S>
impl<T: ?Sized + Eq, H, S: HashStorer> Eq for How<T, H, S>
Auto Trait Implementations§
impl<T, H, S> Freeze for How<T, H, S>
impl<T, H, S> RefUnwindSafe for How<T, H, S>
impl<T, H, S> Send for How<T, H, S>
impl<T, H, S> Sync for How<T, H, S>
impl<T, H, S> Unpin for How<T, H, S>
impl<T, H, S> UnwindSafe for How<T, H, S>
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
Mutably borrows from an owned value. Read more