pub struct SymbolTable { /* private fields */ }Expand description
Interns symbol names to SymbolIds for fast equality checks.
Implementations§
Source§impl SymbolTable
impl SymbolTable
pub fn new() -> SymbolTable
Sourcepub fn intern(&mut self, name: &str) -> SymbolId
pub fn intern(&mut self, name: &str) -> SymbolId
Intern a symbol name, returning its unique ID. If already interned, returns the existing ID.
Sourcepub fn resolve(&self, id: SymbolId) -> &str
pub fn resolve(&self, id: SymbolId) -> &str
Resolve a SymbolId back to its name. Panics if the ID is invalid.
Sourcepub fn try_resolve(&self, id: SymbolId) -> Option<&str>
pub fn try_resolve(&self, id: SymbolId) -> Option<&str>
Try to resolve a SymbolId, returning None if invalid.
Sourcepub fn lookup(&self, name: &str) -> Option<SymbolId>
pub fn lookup(&self, name: &str) -> Option<SymbolId>
Look up a symbol by name without interning it.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Debug for SymbolTable
impl Debug for SymbolTable
Source§impl Default for SymbolTable
impl Default for SymbolTable
Source§fn default() -> SymbolTable
fn default() -> SymbolTable
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Forget for SymbolTable
impl Freeze for SymbolTable
impl Move for SymbolTable
impl RefUnwindSafe for SymbolTable
impl Send for SymbolTable
impl Sync for SymbolTable
impl Unpin for SymbolTable
impl UnsafeUnpin for SymbolTable
impl UnwindSafe for SymbolTable
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