Struct boa_interner::Interner
source · [−]pub struct Interner { /* private fields */ }
Expand description
The string interner for Boa.
Implementations
sourceimpl Interner
impl Interner
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new Interner
with the specified capacity.
sourcepub fn get<T>(&self, string: T) -> Option<Sym>where
T: AsRef<str>,
pub fn get<T>(&self, string: T) -> Option<Sym>where
T: AsRef<str>,
Returns the symbol for the given string if any.
Can be used to query if a string has already been interned without interning.
sourcepub fn get_or_intern<T>(&mut self, string: T) -> Symwhere
T: AsRef<str>,
pub fn get_or_intern<T>(&mut self, string: T) -> Symwhere
T: AsRef<str>,
Interns the given string.
Returns a symbol for resolution into the original string.
Panics
If the interner already interns the maximum number of strings possible by the chosen symbol type.
sourcepub fn get_or_intern_static(&mut self, string: &'static str) -> Sym
pub fn get_or_intern_static(&mut self, string: &'static str) -> Sym
Interns the given 'static
string.
Returns a symbol for resolution into the original string.
Note
This is more efficient than Interner::get_or_intern
, since it
avoids storing string
inside the Interner
.
Panics
If the interner already interns the maximum number of strings possible by the chosen symbol type.
sourcepub fn resolve(&self, symbol: Sym) -> Option<&str>
pub fn resolve(&self, symbol: Sym) -> Option<&str>
Returns the string for the given symbol if any.
sourcepub fn resolve_expect(&self, symbol: Sym) -> &str
pub fn resolve_expect(&self, symbol: Sym) -> &str
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Interner
impl !Send for Interner
impl !Sync for Interner
impl Unpin for Interner
impl UnwindSafe for Interner
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more