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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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
.