pub struct Interner<T: ?Sized + 'static>(/* private fields */);
Expand description
A thread-safe interner which can be used to create Interned<T>
from &T
For details on interning, see the module level docs.
The implementation ensures that two equal values return two equal Interned<T>
values.
To use an Interner<T>
, T
must implement Internable
.
Implementations§
Source§impl<T: Internable + ?Sized> Interner<T>
impl<T: Internable + ?Sized> Interner<T>
Sourcepub fn intern(&self, value: &T) -> Interned<T>
pub fn intern(&self, value: &T) -> Interned<T>
Return the Interned<T>
corresponding to value
.
If it is called the first time for value
, it will possibly leak the value and return an
Interned<T>
using the obtained static reference. Subsequent calls for the same value
will return Interned<T>
using the same static reference.
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for Interner<T>
impl<T> RefUnwindSafe for Interner<T>where
T: ?Sized,
impl<T> Send for Interner<T>
impl<T> Sync for Interner<T>
impl<T> Unpin for Interner<T>where
T: ?Sized,
impl<T> UnwindSafe for Interner<T>where
T: ?Sized,
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
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self
using data from the given World
.