pub struct StringInterner { /* private fields */ }Expand description
Interned string table: AtomId <-> String mapping. Atoms are interned at build time so unification compares integers, not strings.
Implementations§
Source§impl StringInterner
impl StringInterner
pub fn new() -> Self
Sourcepub fn intern(&mut self, s: &str) -> AtomId
pub fn intern(&mut self, s: &str) -> AtomId
Intern a string, returning its AtomId. If already interned, returns existing id.
Sourcepub fn resolve(&self, id: AtomId) -> &str
pub fn resolve(&self, id: AtomId) -> &str
Resolve an AtomId back to its string. Panics if id is invalid.
Sourcepub fn try_resolve(&self, id: AtomId) -> Option<&str>
pub fn try_resolve(&self, id: AtomId) -> Option<&str>
Try to resolve an AtomId, returning None if invalid.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Clone for StringInterner
impl Clone for StringInterner
Source§fn clone(&self) -> StringInterner
fn clone(&self) -> StringInterner
Returns a duplicate 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 StringInterner
impl Debug for StringInterner
Source§impl Default for StringInterner
impl Default for StringInterner
Source§impl<'de> Deserialize<'de> for StringInterner
impl<'de> Deserialize<'de> for StringInterner
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for StringInterner
impl RefUnwindSafe for StringInterner
impl Send for StringInterner
impl Sync for StringInterner
impl Unpin for StringInterner
impl UnsafeUnpin 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