SymbolSource

Struct SymbolSource 

Source
pub struct SymbolSource<T: SymbolPrimitive = NonZeroU32> { /* private fields */ }
Expand description

A source of numeric symbols.

Implementations§

Source§

impl<T: SymbolPrimitive> SymbolSource<T>

Source

pub fn new() -> Self

Creates a source of numeric symbols with an empty symbol space.

Source

pub fn sym<'a, const N: usize>(&mut self) -> [Symbol<T>; N]

Returns generated symbols.

Source

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.

Source

pub fn next_sym(&mut self, name: Option<Cow<'_, str>>) -> Symbol<T>

Generates a new unique symbol.

Source

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.

Source

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).

Source

pub fn num_syms(&self) -> usize

Returns the number of symbols in use.

Source

pub fn generate(&mut self) -> impl Iterator<Item = Symbol<T>> + use<'_, T>

Returns an iterator that generates symbols.

Source

pub fn generate_fresh() -> impl Iterator<Item = Symbol<T>>

Iterator over all possible Symbols, in order, starting with the lowest numeric value.

Source

pub fn remap_symbols<F>(&mut self, map: F)
where F: FnMut(Symbol<T>) -> Symbol<T>,

Translates symbol names according to the given mapping beween Symbols.

Source

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.

Source

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,

Source

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>

Source§

fn clone(&self) -> SymbolSource<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + SymbolPrimitive> Debug for SymbolSource<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default + SymbolPrimitive> Default for SymbolSource<T>

Source§

fn default() -> SymbolSource<T>

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

impl<T> Deserialize for SymbolSource<T>

Source§

fn begin(__out: &mut Option<Self>) -> &mut dyn Visitor

The only correct implementation of this method is: Read more
Source§

impl<T> Serialize for SymbolSource<T>

Source§

fn begin(&self) -> Fragment<'_>

Auto Trait Implementations§

§

impl<T> Freeze for SymbolSource<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SymbolSource<T>
where T: RefUnwindSafe,

§

impl<T = NonZero<u32>> !Send for SymbolSource<T>

§

impl<T = NonZero<u32>> !Sync for SymbolSource<T>

§

impl<T> Unpin for SymbolSource<T>
where T: Unpin,

§

impl<T> UnwindSafe for SymbolSource<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.