Struct internment::Intern [−][src]
pub struct Intern<T: 'static> { /* fields omitted */ }
Implementations
Intern a value. If this value has not previously been
interned, then new
will allocate a spot for the value on the
heap. Otherwise, it will return a pointer to the object
previously allocated.
Note that Intern::new
is a bit slow, since it needs to check
a HashSet
protected by a Mutex
.
Intern a value from a reference.
If this value has not previously been
interned, then new
will allocate a spot for the value on the
heap and generate that value using T::from(val)
.
Get a long-lived reference to the data pointed to by an Intern
, which
is never freed from the intern pool.
See how many objects have been interned. This may be helpful in analyzing memory use.
Trait Implementations
The hash implementation returns the hash of the pointer value, not the hash of the value pointed to. This should be irrelevant, since there is a unique pointer for every value, but it is observable, since you could compare the hash of the pointer with hash of the data itself.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
An Intern
is Copy
, which is unusal for a pointer. This is safe
because we never free the data pointed to by an Intern
.
Auto Trait Implementations
impl<T> RefUnwindSafe for Intern<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Intern<T> where
T: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> CallHasher for T where
T: Hash,
impl<T> CallHasher for T where
T: Hash,