Struct tiny_interner::Interner
source · pub struct Interner<H = DefaultHashBuilder>where
H: BuildHasher,{ /* private fields */ }Expand description
Data structure that allows to resolve/intern strings.
See:
Interner::get_or_internto intern a new string.Interner::resolveto resolve already interned strings.
Implementations§
source§impl<H> Interner<H>where
H: BuildHasher + Default,
impl<H> Interner<H>where H: BuildHasher + Default,
sourcepub fn with_hasher(hasher: H) -> Self
pub fn with_hasher(hasher: H) -> Self
Creates a new empty Interner with the given hasher.
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new empty Interner with the given capacity.
sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: H) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hasher: H) -> Self
Creates a new empty Interner with the given capacity and hasher.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the string interner has no interned strings/amount of symbols is 0.
sourcepub fn get<T>(&self, string: T) -> Option<usize>where
T: AsRef<str>,
pub fn get<T>(&self, string: T) -> Option<usize>where T: AsRef<str>,
Returns the symbol for the given string if any.
sourcepub fn get_or_intern<T>(&mut self, string: T) -> usizewhere
T: AsRef<str>,
pub fn get_or_intern<T>(&mut self, string: T) -> usizewhere T: AsRef<str>,
Interns the given string and returns a corresponding symbol.
sourcepub fn get_or_intern_static(&mut self, string: &'static str) -> usize
pub fn get_or_intern_static(&mut self, string: &'static str) -> usize
Interns the given 'static string and returns a corresponding symbol.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink backend capacity to fit the interned strings exactly.
Trait Implementations§
Auto Trait Implementations§
impl<H> RefUnwindSafe for Interner<H>where H: RefUnwindSafe,
impl<H> Send for Interner<H>where H: Send,
impl<H> Sync for Interner<H>where H: Sync,
impl<H> Unpin for Interner<H>where H: Unpin,
impl<H> UnwindSafe for Interner<H>where H: UnwindSafe,
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