pub trait Expand<I> {
type Output: ToTokens;
// Required method
fn expand(&self, input: &I, c: &mut Collector) -> Option<Self::Output>;
}Expand description
Expand is used for expanding macros
§Example
use macro_compose::{Collector, Expand};
use syn::{parse_quote, DeriveInput, Error, ItemImpl};
struct ImplFooExpand;
impl Expand<DeriveInput> for ImplFooExpand {
type Output = ItemImpl;
fn expand(&self, input: &DeriveInput, c: &mut Collector) -> Option<Self::Output> {
let ident = &input.ident;
Some(parse_quote!(
impl Foo for #ident {
fn bar(&self) {}
}
))
}
}Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".