pub struct SymbolSource<T: SymbolPrimitive = NonZeroU32> { /* private fields */ }Expand description
A source of numeric symbols.
Implementations§
Source§impl<T: SymbolPrimitive> SymbolSource<T>
impl<T: SymbolPrimitive> SymbolSource<T>
Sourcepub fn with_names<'a, const N: usize, S: Into<Cow<'static, str>>>(
&mut self,
names: [Option<S>; N],
) -> [Symbol<T>; N]
pub fn with_names<'a, const N: usize, S: Into<Cow<'static, str>>>( &mut self, names: [Option<S>; N], ) -> [Symbol<T>; N]
Returns generated symbols.
Sourcepub fn next_sym(&mut self, name: Option<Cow<'_, str>>) -> Symbol<T>
pub fn next_sym(&mut self, name: Option<Cow<'_, str>>) -> Symbol<T>
Generates a new unique symbol.
Sourcepub fn name_of(&self, sym: Symbol) -> Cow<'_, str>
pub fn name_of(&self, sym: Symbol) -> Cow<'_, str>
Returns either the formatted name if the given Symbol is a gensym,
or the Symbol’s exact name.
Gensyms have no names. That’s why we create a ‘formatted’ name
with the letter g followed by the symbol’s numeric value.
Sourcepub fn original_name_of(&self, sym: Symbol) -> Option<&str>
pub fn original_name_of(&self, sym: Symbol) -> Option<&str>
Returns the exact name, or None if the Symbol has no name (i.e.
is a gensym).
Sourcepub fn generate(&mut self) -> impl Iterator<Item = Symbol<T>> + use<'_, T>
pub fn generate(&mut self) -> impl Iterator<Item = Symbol<T>> + use<'_, T>
Returns an iterator that generates symbols.
Sourcepub fn generate_fresh() -> impl Iterator<Item = Symbol<T>>
pub fn generate_fresh() -> impl Iterator<Item = Symbol<T>>
Iterator over all possible Symbols, in order, starting with the lowest
numeric value.
Sourcepub fn remap_symbols<F>(&mut self, map: F)
pub fn remap_symbols<F>(&mut self, map: F)
Translates symbol names according to the given mapping
beween Symbols.
Sourcepub fn truncate(&mut self, new_len: usize)
pub fn truncate(&mut self, new_len: usize)
Removes all the symbols with numeric value equal or higher than the argument.
§Panics
Panics unless new_len is within 1 ..= T::MAX.
Sourcepub fn names(&self) -> Vec<Option<SymbolName>>
pub fn names(&self) -> Vec<Option<SymbolName>>
Returns the list of Symbol names.
§Performance
Internally, bumps the reference count for every existing SymbolName
and copies the pointers to a newly allocated a new Vec,
Sourcepub fn name_map(&self) -> HashMap<SymbolName, Symbol>
pub fn name_map(&self) -> HashMap<SymbolName, Symbol>
Creates a HashMap where you can access a Symbol
through its name.
Trait Implementations§
Source§impl<T: Clone + SymbolPrimitive> Clone for SymbolSource<T>
impl<T: Clone + SymbolPrimitive> Clone for SymbolSource<T>
Source§fn clone(&self) -> SymbolSource<T>
fn clone(&self) -> SymbolSource<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more