pub struct Intern<'a, T: 'a>(/* private fields */);
Expand description
A reference to an interned item.
The main advantage of this type over just
an immutable reference is that its pointer is guaranteed to be unique
within a single Interner
. Therefore comparisons
are very cheap.
§Note about hashing
This wrapper implements PartialEq
by comparing its inner pointer.
In order to keep consistency, the Hash
trait is also implemented
by hashing the pointer, NOT the inner value. Therefore hashes
of the Intern<T>
type are different than hashes of the T
.
Implementations§
Trait Implementations§
Source§impl<'a, T> Hash for Intern<'a, T>
To keep consistency with PartialEq
, we hash the pointer, not the value
impl<'a, T> Hash for Intern<'a, T>
To keep consistency with PartialEq
, we hash the pointer, not the value
Source§impl<'a, T: Ord> Ord for Intern<'a, T>
impl<'a, T: Ord> Ord for Intern<'a, T>
Source§impl<'a, T: PartialOrd> PartialOrd for Intern<'a, T>
impl<'a, T: PartialOrd> PartialOrd for Intern<'a, T>
impl<'a, T> Copy for Intern<'a, T>
impl<'a, T> Eq for Intern<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for Intern<'a, T>
impl<'a, T> RefUnwindSafe for Intern<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Intern<'a, T>where
T: Sync,
impl<'a, T> Sync for Intern<'a, T>where
T: Sync,
impl<'a, T> Unpin for Intern<'a, T>
impl<'a, T> UnwindSafe for Intern<'a, T>where
T: RefUnwindSafe,
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