Skip to main content

MacroCx

Struct MacroCx 

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

Expansion context passed to macros: the evaluation context, current phase, environment, expansion budget, and the active macro stack.

Implementations§

Source§

impl<'a> MacroCx<'a>

Source

pub fn new(cx: &'a mut Cx, phase: Phase) -> Self

Creates an expansion context with the default expansion limits.

Source

pub fn with_limits( cx: &'a mut Cx, phase: Phase, limits: MacroExpansionLimits, ) -> Self

Creates an expansion context with explicit expansion limits.

Source

pub fn phase(&self) -> Phase

Returns the phase the macro is being expanded in.

Source

pub fn env(&self) -> &Env

Returns the environment captured for this expansion.

Source

pub fn factory(&self) -> &dyn Factory

Returns the object factory of the underlying context.

Source

pub fn quote_expr(&self, expr: Expr) -> Result<Value>

Quotes an expression into a value through the factory.

Source

pub fn hygienic_symbol(&mut self, prefix: impl AsRef<str>) -> Symbol

Generates a fresh hygienic symbol scoped to the active macro.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for MacroCx<'a>

§

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

§

impl<'a> Freeze for MacroCx<'a>

§

impl<'a> Send for MacroCx<'a>

§

impl<'a> Sync for MacroCx<'a>

§

impl<'a> Unpin for MacroCx<'a>

§

impl<'a> UnsafeUnpin for MacroCx<'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<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> Same for T

Source§

type Output = T

Should always be Self
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.