[][src]Trait macro_compose::Expand

pub trait Expand<I> {
    type Output: ToTokens;
    fn expand(&self, input: &I, c: &mut Collector) -> Option<Self::Output>;
}

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) {}
            }   
        ))
    }
}

Associated Types

type Output: ToTokens

the output generated by the expansion

Loading content...

Required methods

fn expand(&self, input: &I, c: &mut Collector) -> Option<Self::Output>

expand the macro

Loading content...

Implementors

impl<T: ToTokens + Clone> Expand<T> for EchoExpand[src]

type Output = T

Loading content...