pub struct ThreadedInterner { /* private fields */ }Expand description
A thread-safe interner, allowing multiple threads to concurrently intern strings.
Implementations§
Source§impl ThreadedInterner
impl ThreadedInterner
Sourcepub fn intern(&self, string: impl AsRef<str>) -> StringIdentifier
pub fn intern(&self, string: impl AsRef<str>) -> StringIdentifier
Interns a string and returns its identifier.
If the string is already interned, the existing identifier is returned.
§Arguments
string- The string to intern.
Sourcepub fn interned_str(&self, string: impl AsRef<str>) -> &str
pub fn interned_str(&self, string: impl AsRef<str>) -> &str
Interns a string if it has not already been interned, then returns a reference to the interned string.
§Arguments
string- A string or any type that implementsAsRef<str>, representing the string to intern.
§Returns
A reference to the interned version of the string.
§Panics
This method will panic if it encounters an invalid identifier. This should never occur unless there is an issue with the identifier or the interner is used incorrectly.
Sourcepub fn lowered(&self, identifier: &StringIdentifier) -> StringIdentifier
pub fn lowered(&self, identifier: &StringIdentifier) -> StringIdentifier
Sourcepub fn lookup(&self, identifier: &StringIdentifier) -> &str
pub fn lookup(&self, identifier: &StringIdentifier) -> &str
Sourcepub fn all(&self) -> HashSet<(StringIdentifier, &str)>
pub fn all(&self) -> HashSet<(StringIdentifier, &str)>
Returns all interned strings and their identifiers as a hashmap.
Trait Implementations§
Source§impl Clone for ThreadedInterner
impl Clone for ThreadedInterner
Source§fn clone(&self) -> ThreadedInterner
fn clone(&self) -> ThreadedInterner
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ThreadedInterner
impl Debug for ThreadedInterner
Source§impl Default for ThreadedInterner
impl Default for ThreadedInterner
impl Send for ThreadedInterner
impl Sync for ThreadedInterner
Auto Trait Implementations§
impl Freeze for ThreadedInterner
impl !RefUnwindSafe for ThreadedInterner
impl Unpin for ThreadedInterner
impl !UnwindSafe for ThreadedInterner
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