Struct boa_interner::Interner
source · pub struct Interner { /* private fields */ }
Expand description
The string interner for Boa.
Implementations§
source§impl 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<'a, T>(&self, string: T) -> Option<Sym>
pub fn get<'a, T>(&self, string: T) -> Option<Sym>
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<'a, T>(&mut self, string: T) -> Sym
pub fn get_or_intern<'a, T>(&mut self, string: T) -> Sym
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,
utf8: &'static str,
utf16: &'static [u16]
) -> Sym
pub fn get_or_intern_static( &mut self, utf8: &'static str, utf16: &'static [u16] ) -> 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 allocating space
for one string
inside the Interner
, with the disadvantage that you need to provide
both the UTF-8
and the UTF-16
representation of the string.
§Panics
If the interner already interns the maximum number of strings possible by the chosen symbol type.
sourcepub fn resolve(&self, symbol: Sym) -> Option<JSInternedStrRef<'_, '_>>
pub fn resolve(&self, symbol: Sym) -> Option<JSInternedStrRef<'_, '_>>
Returns the string for the given symbol if any.
§Panics
Panics if the size of both statics is not equal or the interners do not have the same size