Trait manyhow::DeriveMacroHandler

source ·
pub trait DeriveMacroHandler<Function> {
    type Item;
    type Dummy;
    type Output;

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

Input of a derive proc-macro

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

Trait is implemented for any function, taking in one TokenStream. 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 derive() it must return a type implementing MacroOutput, with derive! it can accept types implementing Parse and return types implementing ToTokens.

Required Associated Types§

Required Methods§

source

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

Implementors§

source§

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

§

type Dummy = Dummy

§

type Item = Item

§

type Output = Output

source§

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

§

type Dummy = Dummy

§

type Item = Item

§

type Output = Output

source§

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

§

type Dummy = TokenStream

§

type Item = Item

§

type Output = Output

source§

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

§

type Dummy = TokenStream

§

type Item = Item

§

type Output = Output