pub struct Interner<H = DefaultHashBuilder>where
H: BuildHasher,{ /* private fields */ }
Expand description
Data structure that allows to resolve/intern strings.
See:
Interner::get_or_intern
to intern a new string.Interner::resolve
to 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>
pub fn get<T>(&self, string: T) -> Option<usize>
Returns the symbol for the given string if any.
Sourcepub fn get_or_intern<T>(&mut self, string: T) -> usize
pub fn get_or_intern<T>(&mut self, string: T) -> usize
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> Freeze for Interner<H>where
H: Freeze,
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