pub struct StringInterner<'src> { /* private fields */ }Expand description
String interner for query compilation.
Interns strings during the analysis phase, then emits them as a contiguous
byte pool with StringRef entries pointing into it.
Implementations§
Source§impl<'src> StringInterner<'src>
impl<'src> StringInterner<'src>
Sourcepub fn intern(&mut self, s: &'src str) -> StringId
pub fn intern(&mut self, s: &'src str) -> StringId
Interns a string, returning its ID.
If the string was previously interned, returns the existing ID.
Sourcepub fn get(&self, s: &str) -> Option<StringId>
pub fn get(&self, s: &str) -> Option<StringId>
Returns the ID of a previously interned string, or None.
Sourcepub fn iter(&self) -> impl Iterator<Item = (StringId, &'src str)> + '_
pub fn iter(&self) -> impl Iterator<Item = (StringId, &'src str)> + '_
Returns an iterator over (id, string) pairs in ID order.
Sourcepub fn total_bytes(&self) -> usize
pub fn total_bytes(&self) -> usize
Returns the total byte size needed for all strings.
Sourcepub fn into_strings(self) -> Vec<&'src str>
pub fn into_strings(self) -> Vec<&'src str>
Consumes the interner and returns strings in ID order.
Trait Implementations§
Source§impl<'src> Debug for StringInterner<'src>
impl<'src> Debug for StringInterner<'src>
Source§impl<'src> Default for StringInterner<'src>
impl<'src> Default for StringInterner<'src>
Source§fn default() -> StringInterner<'src>
fn default() -> StringInterner<'src>
Returns the “default value” for a type. Read more