Skip to main content

MacroCtx

Struct MacroCtx 

Source
pub struct MacroCtx<'r> {
    pub line: u32,
    pub span: Span,
    /* private fields */
}
Expand description

Context passed to every macro expand invocation: gives access to the gensym counter (for hygienic identifier minting) and a back- reference to the registry (so a macro can call other macros programmatically — @if uses this to expand its chosen arm).

Fields§

§line: u32

Line of the @name invocation, for error attribution.

§span: Span

Source span of the invocation (@ byte through last )/}), for Token::describe slicing on synthesized tokens.

Implementations§

Source§

impl<'r> MacroCtx<'r>

Source

pub fn gensym(&mut self, prefix: &str) -> Box<str>

Mint a fresh identifier name like __lm_42_tmp. Used by @gensym and any host-side macro that needs hygiene.

Auto Trait Implementations§

§

impl<'r> !RefUnwindSafe for MacroCtx<'r>

§

impl<'r> !Send for MacroCtx<'r>

§

impl<'r> !Sync for MacroCtx<'r>

§

impl<'r> !UnwindSafe for MacroCtx<'r>

§

impl<'r> Freeze for MacroCtx<'r>

§

impl<'r> Unpin for MacroCtx<'r>

§

impl<'r> UnsafeUnpin for MacroCtx<'r>

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.