pub struct SymbolTable { /* private fields */ }Expand description
A set of strings. Unlike a regular set, strings are stored contiguously in pages to reduce memory usage.
Implementations§
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty table.
Unlike many types in alloc, this allocates right away.
Sourcepub fn intern(&self, text: impl Into<String> + AsRef<str>) -> Symbol<'_>
pub fn intern(&self, text: impl Into<String> + AsRef<str>) -> Symbol<'_>
Adds a symbol to the table if it does not exist.
§Example
let table = SymbolTable::new();
assert_eq!(table.intern("my symbol"), table.intern("my symbol"));Sourcepub fn gensym(&self, text: impl Into<String> + AsRef<str>) -> Symbol<'_>
pub fn gensym(&self, text: impl Into<String> + AsRef<str>) -> Symbol<'_>
Adds a symbol to the table. This symbol is always considered distinct from all other symbols even if they are textually identical.
§Example
let table = SymbolTable::new();
assert_ne!(table.intern("my symbol"), table.gensym("my symbol"));§Name
The name “gensym” is common within the Lisp family of languages where symbols are built in
the language itself.
Trait Implementations§
Source§impl Default for SymbolTable
impl Default for SymbolTable
Auto Trait Implementations§
impl !Freeze for SymbolTable
impl !RefUnwindSafe for SymbolTable
impl !Send for SymbolTable
impl !Sync for SymbolTable
impl Unpin 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