pub struct SymbolModule<'a> { /* private fields */ }
Expand description

SymbolModule wraps a Symbols struct and adds a prefix to all symbols created by the symbol method. While this prefix does not affect the uniques of a Symbol in any way, it does make the origin of a symbol clearer when pretty printing it

Implementations§

source§

impl<'a> SymbolModule<'a>

source

pub fn new(module: String, symbols: &'a mut Symbols) -> SymbolModule<'a>

source

pub fn simple_symbol<N>(&mut self, name: N) -> Symbol
where N: Into<NameBuf> + AsRef<Name>,

source

pub fn symbol<N>(&mut self, name: SymbolData<N>) -> Symbol
where N: Into<NameBuf> + AsRef<Name>,

Creates an unprefixed symbol, same as Symbols::symbol

source

pub fn contains_name<N>(&mut self, name: N) -> bool
where N: AsRef<Name>,

source

pub fn scoped_symbol(&mut self, name: &str) -> Symbol

Creates a symbol which is prefixed by the module argument passed in new

let mut symbols = Symbols::new();
let mut symbols = SymbolModule::new(String::from("test"), &mut symbols);
assert_eq!(symbols.simple_symbol("a").as_ref(), "a");
assert_eq!(symbols.scoped_symbol("a").as_ref(), "test.a");
source

pub fn module(&self) -> &Name

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn symbols(&mut self) -> &mut Symbols

Trait Implementations§

source§

impl<'a> Debug for SymbolModule<'a>

source§

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

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

impl<'s> DisplayEnv for SymbolModule<'s>

§

type Ident = Symbol

source§

fn string<'a>(&'a self, ident: &'a Self::Ident) -> &'a str

source§

impl<'a> IdentEnv for SymbolModule<'a>

source§

fn from_str(&mut self, s: &str) -> Symbol

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for SymbolModule<'a>

§

impl<'a> Send for SymbolModule<'a>

§

impl<'a> Sync for SymbolModule<'a>

§

impl<'a> Unpin for SymbolModule<'a>

§

impl<'a> !UnwindSafe for SymbolModule<'a>

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<Id> AsId<Id> for Id
where Id: ?Sized,

source§

fn as_id(&self) -> &Id

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>,

§

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>,

§

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

impl<T> Any for T
where T: Any,