Struct scale_info::interner::Interner
source · pub struct Interner<T> { /* private fields */ }
Expand description
Interning data structure generic over the element type.
For the sake of simplicity and correctness we are using a rather naive implementation.
Usage
This is used in order to quite efficiently cache strings and type definitions uniquely identified by their associated type identifiers.
Implementations§
source§impl<T> Interner<T>where
T: Ord + Clone,
impl<T> Interner<T>where
T: Ord + Clone,
sourcepub fn intern_or_get(&mut self, s: T) -> (bool, Symbol<'_, T>)
pub fn intern_or_get(&mut self, s: T) -> (bool, Symbol<'_, T>)
Interns the given element or returns its associated symbol if it has already been interned.
sourcepub fn get(&self, sym: &T) -> Option<Symbol<'_, T>>
pub fn get(&self, sym: &T) -> Option<Symbol<'_, T>>
Returns the symbol of the given element or None
if it hasn’t been
interned already.