Struct intern_all::Tok
source · pub struct Tok<T: Eq + Hash + Clone + 'static> { /* private fields */ }Expand description
A number representing an object of type T stored in some interner.
Equality comparison costs two pointer comparisons. Ordering is by pointer
value.
Panics
Comparison panics if values from different interners are involved. Since a given Interner uses a single TypedInterner for each type, this is only possible if either multiple Interner or TypedInterner instances are constructed.
Implementations§
source§impl<T: Eq + Hash + Clone + 'static> Tok<T>
impl<T: Eq + Hash + Clone + 'static> Tok<T>
sourcepub fn id(&self) -> NonZeroUsize
pub fn id(&self) -> NonZeroUsize
The pointer value of the token. If this is equal, equality comparison succeeds.
sourcepub fn interner_id(&self) -> NonZeroUsize
pub fn interner_id(&self) -> NonZeroUsize
The pointer value of the interner. If this is different, comparison panics.
sourcepub fn assert_comparable(&self, other: &Self)
pub fn assert_comparable(&self, other: &Self)
Panic if the two tokens weren’t created with the same interner
sourcepub fn interner(&self) -> Arc<TypedInterner<T>>
pub fn interner(&self) -> Arc<TypedInterner<T>>
Get the interner that owns this token. It is safe to use this even if the token was created with Interner.
source§impl<T: Eq + Hash + Clone + 'static> Tok<Vec<Tok<T>>>
impl<T: Eq + Hash + Clone + 'static> Tok<Vec<Tok<T>>>
sourcepub fn ev(&self) -> Vec<T>
pub fn ev(&self) -> Vec<T>
Extern all elements of the vector in a new vector. If the vector itself isn’t interned, use Interner::ev
source§impl<T: Eq + Hash + Clone + Send + Sync + 'static> Tok<Vec<Tok<T>>>
impl<T: Eq + Hash + Clone + Send + Sync + 'static> Tok<Vec<Tok<T>>>
sourcepub fn append<'a>(
&self,
i: &Interner,
suffix: impl IntoIterator<Item = &'a T>
) -> Self
pub fn append<'a>( &self, i: &Interner, suffix: impl IntoIterator<Item = &'a T> ) -> Self
Add a suffix to the interned vector
sourcepub fn prepend<'a>(
&self,
i: &Interner,
prefix: impl IntoIterator<Item = &'a T>
) -> Self
pub fn prepend<'a>( &self, i: &Interner, prefix: impl IntoIterator<Item = &'a T> ) -> Self
Add a prefix to the interned vector
Trait Implementations§
source§impl<T: Eq + Hash + Clone + 'static> Ord for Tok<T>
impl<T: Eq + Hash + Clone + 'static> Ord for Tok<T>
source§impl<T: Eq + Hash + Clone + 'static> PartialEq for Tok<T>
impl<T: Eq + Hash + Clone + 'static> PartialEq for Tok<T>
source§impl<T: Eq + Hash + Clone + 'static> PartialOrd for Tok<T>
impl<T: Eq + Hash + Clone + 'static> PartialOrd for Tok<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more