Struct bevy_utils::intern::Interned
source · pub struct Interned<T: ?Sized + 'static>(pub &'static T);
Expand description
An interned value. Will stay valid until the end of the program and will not drop.
For details on interning, see the module level docs.
Comparisons
Interned values use reference equality, meaning they implement Eq
and Hash
regardless of whether T
implements these traits.
Two interned values are only guaranteed to compare equal if they were interned using
the same Interner
instance.
#[derive(PartialEq, Eq, Hash, Debug)]
struct Value(i32);
impl Internable for Value {
// ...
}
let interner_1 = Interner::new();
let interner_2 = Interner::new();
// Even though both values are identical, their interned forms do not
// compare equal as they use different interner instances.
assert_ne!(interner_1.intern(&Value(42)), interner_2.intern(&Value(42)));
Tuple Fields§
§0: &'static T
Trait Implementations§
source§impl<T: ?Sized + Internable> PartialEq for Interned<T>
impl<T: ?Sized + Internable> PartialEq for Interned<T>
impl<T: ?Sized> Copy for Interned<T>
impl<T: ?Sized + Internable> Eq for Interned<T>
Auto Trait Implementations§
impl<T: ?Sized> RefUnwindSafe for Interned<T>where
T: RefUnwindSafe,
impl<T: ?Sized> Send for Interned<T>where
T: Sync,
impl<T: ?Sized> Sync for Interned<T>where
T: Sync,
impl<T: ?Sized> Unpin for Interned<T>
impl<T: ?Sized> UnwindSafe for Interned<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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.