pub(crate) fn gen_function<'a, B: ToTokens + 'a>(
    input: MaybeItemFnRef<'a, B>,
    args: InstrumentArgs,
    instrumented_function_name: &str,
    self_type: Option<&syn::TypePath>,
) -> proc_macro2::TokenStream {
    // these are needed ahead of time, as ItemFn contains the function body _and_
    // isn't representable inside a quote!/quote_spanned! macro
    // (Syn's ToTokens isn't implemented for ItemFn)
    let MaybeItemFnRef {
        attrs,
        vis,
        sig,
        block,
    } = input;

    let Signature {
        output: return_type,
        inputs: params,
        unsafety,
        asyncness,
        constness,
        abi,
        ident,
        generics:
            syn::Generics {
                params: gen_params,
                where_clause,
                ..
            },
        ..
    } = sig;

    let warnings = args.warnings();

    let body = gen_block(
        block,
        params,
        asyncness.is_some(),
        args,
        instrumented_function_name,
        self_type,
    );

    quote!(
        #(#attrs) *
        #vis #constness #unsafety #asyncness #abi fn #ident<#gen_params>(#params) #return_type
        #where_clause
        {
            #warnings
            #body
        }
    )
}
/// Given an existing function, generate an instrumented version of that function
Given an existing function, generate an instrumented version of that function
Given an existing function generate an instrumented version of that function
pub(crate) fn gen_function<'a, B: ToTokens + 'a>(
    input: MaybeItemFnRef<'a, B>,
    args: InstrumentArgs,
    instrumented_function_name: &str,
    self_type: Option<&syn::TypePath>,
) -> proc_macro2::TokenStream {
    // these are needed ahead of time, as ItemFn contains the function body _and_
    // isn't representable inside a quote!/quote_spanned! macro
    // (Syn's ToTokens isn't implemented for ItemFn)
    let MaybeItemFnRef {
        attrs,
        vis,
        sig,
        block,
    } = input;
    let Signature {
        output: return_type,
        inputs: params,
        unsafety,
        asyncness,
        constness,
        abi,
        ident,
        generics:
            syn::Generics {
                params: gen_params,
                where_clause,
                ..
            },
        ..
    } = sig;
    let warnings = args.warnings();
    let body = gen_block(
        block,
        params,
        asyncness.is_some(),
        args,
        instrumented_function_name,
        self_type,
    );
    quote!(
        #(#attrs) *
        #vis #constness #unsafety #asyncness #abi fn #ident<#gen_params>(#params) #return_type
        #where_clause
        {
            #warnings
            #body
        }
    )
}
pub ( crate ) fn gen_function < ' a , B : ToTokens + ' a > ( input : MaybeItemFnRef < ' a , B > , args : InstrumentArgs , instrumented_function_name : & str , self_type : Option < & syn :: TypePath > , ) -> proc_macro2 :: TokenStream { // these are needed ahead of time, as ItemFn contains the function body _and_ // isn't representable inside a quote!/quote_spanned! macro // (Syn's ToTokens isn't implemented for ItemFn) let MaybeItemFnRef { attrs , vis , sig , block , } = input ; let Signature { output : return_type , inputs : params , unsafety , asyncness , constness , abi , ident , generics : syn :: Generics { params : gen_params , where_clause , .. } , .. } = sig ; let warnings = args . warnings ( ) ; let body = gen_block ( block , params , asyncness . is_some ( ) , args , instrumented_function_name , self_type , ) ; quote ! ( ( attrs ) vis constness unsafety asyncness abi fn ident gen_params ( params ) return_type where_clause { warnings body } ) }
Given an existing function, generate an instrumented version of that function
Given an existing function generate an instrumented version of that function
input
MaybeItemFnRef<'a, B>
args
InstrumentArgs
instrumented_function_name
&str
self_type
Option<&syn::TypePath>