Trait AttributeMacroHandler

Source
pub trait AttributeMacroHandler<Function> {
    type Input;
    type Item;
    type Dummy;
    type Output;

    // Required method
    fn call(
        self,
        item: Self::Input,
        item: Self::Item,
        dummy: &mut Self::Dummy,
        emitter: &mut Emitter,
    ) -> Self::Output;
}
Expand description

Input of an attribute proc-macro

Note: for TokenStream either proc_macro::TokenStream or proc_macro2::TokenStream can be used.

Trait is implemented for any function, taking in two TokenStreams. Additionally, they can take optionally in any order a &mut Emitter which allows emitting errors without returning early. And a &mut TokenStream to return a dummy TokenStream on failure.

When used with attribute() it must return a type implementing MacroOutput, with attribute! it can accept types implementing Parse and return types implementing ToTokens.

Required Associated Types§

Required Methods§

Source

fn call( self, item: Self::Input, item: Self::Item, dummy: &mut Self::Dummy, emitter: &mut Emitter, ) -> Self::Output

Implementors§

Source§

impl<Input, Item, Dummy: Clone, Output, Function> AttributeMacroHandler<(Input, Item, &mut Dummy, &mut Emitter, Output)> for Function
where Function: Fn(Input, Item, &mut Dummy, &mut Emitter) -> Output,

Source§

type Dummy = Dummy

Source§

type Input = Input

Source§

type Item = Item

Source§

type Output = Output

Source§

impl<Input, Item, Dummy: Clone, Output, Function> AttributeMacroHandler<(Input, Item, &mut Dummy, Output)> for Function
where Function: Fn(Input, Item, &mut Dummy) -> Output,

Source§

type Dummy = Dummy

Source§

type Input = Input

Source§

type Item = Item

Source§

type Output = Output

Source§

impl<Input, Item, Output, Function> AttributeMacroHandler<(Input, Item, &mut Emitter, Output)> for Function
where Function: Fn(Input, Item, &mut Emitter) -> Output,

Source§

type Dummy = TokenStream

Source§

type Input = Input

Source§

type Item = Item

Source§

type Output = Output

Source§

impl<Input, Item, Output, Function> AttributeMacroHandler<(Input, Item, Output)> for Function
where Function: Fn(Input, Item) -> Output,

Source§

type Dummy = TokenStream

Source§

type Input = Input

Source§

type Item = Item

Source§

type Output = Output