pub struct StringInterner { /* private fields */ }Expand description
String interner for deduplicating strings
Implementations§
Source§impl StringInterner
impl StringInterner
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
Sourcepub fn intern(&mut self, s: &str) -> StringId
pub fn intern(&mut self, s: &str) -> StringId
Intern a string, returning its ID If the string is already interned, returns the existing ID
Sourcepub fn get_id(&self, s: &str) -> Option<StringId>
pub fn get_id(&self, s: &str) -> Option<StringId>
Get the ID of an already-interned string without interning
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Returns memory usage in bytes (approximate)
Sourcepub fn iter(&self) -> impl Iterator<Item = (StringId, &str)> + '_
pub fn iter(&self) -> impl Iterator<Item = (StringId, &str)> + '_
Iterate over all interned strings with their IDs
Sourcepub fn stats(&self) -> InternerStats
pub fn stats(&self) -> InternerStats
Get statistics about the interner
Trait Implementations§
Source§impl Debug for StringInterner
impl Debug for StringInterner
Auto Trait Implementations§
impl Freeze for StringInterner
impl RefUnwindSafe for StringInterner
impl Send for StringInterner
impl Sync for StringInterner
impl Unpin for StringInterner
impl UnwindSafe for StringInterner
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more