pub trait Macro: Trace + DowncastArc + Send + Sync {
// Required method
fn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>(
&self,
env: &'b mut MacroExpander<'a>,
symbols: &'c mut Symbols,
arena: &'b mut OwnedArena<'ast, Symbol>,
args: &'b mut [SpannedExpr<'ast, Symbol>]
) -> MacroFuture<'r, 'ast>;
// Provided methods
fn get_capability<T>(
&self,
thread: &Thread,
arc_self: &Arc<dyn Macro>
) -> Option<T>
where Self: Sized,
T: Any { ... }
fn get_capability_impl(
&self,
thread: &Thread,
arc_self: &Arc<dyn Macro>,
id: TypeId
) -> Option<Box<dyn Any>> { ... }
}
Expand description
A trait which abstracts over macros.
A macro is similiar to a function call but is run at compile time instead of at runtime.
Required Methods§
sourcefn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>(
&self,
env: &'b mut MacroExpander<'a>,
symbols: &'c mut Symbols,
arena: &'b mut OwnedArena<'ast, Symbol>,
args: &'b mut [SpannedExpr<'ast, Symbol>]
) -> MacroFuture<'r, 'ast>
fn expand<'r, 'a: 'r, 'b: 'r, 'c: 'r, 'ast: 'r>( &self, env: &'b mut MacroExpander<'a>, symbols: &'c mut Symbols, arena: &'b mut OwnedArena<'ast, Symbol>, args: &'b mut [SpannedExpr<'ast, Symbol>] ) -> MacroFuture<'r, 'ast>
Creating a symbol in symbols
will put it in the same scope as the code surrounding the
expansion. If you want to create a unique symbol then call Symbol::from
or create a new
Symbols
table
Provided Methods§
fn get_capability<T>( &self, thread: &Thread, arc_self: &Arc<dyn Macro> ) -> Option<T>
fn get_capability_impl( &self, thread: &Thread, arc_self: &Arc<dyn Macro>, id: TypeId ) -> Option<Box<dyn Any>>
Implementations§
source§impl dyn Macro
impl dyn Macro
sourcepub fn is<__T: Macro>(&self) -> bool
pub fn is<__T: Macro>(&self) -> bool
Returns true if the trait object wraps an object of type __T
.
sourcepub fn downcast<__T: Macro>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
pub fn downcast<__T: Macro>(self: Box<Self>) -> Result<Box<__T>, Box<Self>>
Returns a boxed object from a boxed trait object if the underlying object is of type
__T
. Returns the original boxed trait if it isn’t.
sourcepub fn downcast_rc<__T: Macro>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
pub fn downcast_rc<__T: Macro>(self: Rc<Self>) -> Result<Rc<__T>, Rc<Self>>
Returns an Rc
-ed object from an Rc
-ed trait object if the underlying object is of
type __T
. Returns the original Rc
-ed trait if it isn’t.
sourcepub fn downcast_ref<__T: Macro>(&self) -> Option<&__T>
pub fn downcast_ref<__T: Macro>(&self) -> Option<&__T>
Returns a reference to the object within the trait object if it is of type __T
, or
None
if it isn’t.
sourcepub fn downcast_mut<__T: Macro>(&mut self) -> Option<&mut __T>
pub fn downcast_mut<__T: Macro>(&mut self) -> Option<&mut __T>
Returns a mutable reference to the object within the trait object if it is of type
__T
, or None
if it isn’t.