SymbolTable

Struct SymbolTable 

Source
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

Source

pub fn new() -> Self

Create an empty table.

Unlike many types in alloc, this allocates right away.

Source

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"));
Source

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

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for SymbolTable

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.