[][src]Type Definition syn::AttributeArgs

type AttributeArgs = Vec<NestedMeta>;

Conventional argument type associated with an invocation of an attribute macro.

For example if we are developing an attribute macro that is intended to be invoked on function items as follows:

#[my_attribute(path = "/v1/refresh")]
pub fn refresh() {
    /* ... */
}

The implementation of this macro would want to parse its attribute arguments as type AttributeArgs.

use proc_macro::TokenStream;
use syn::{parse_macro_input, AttributeArgs, ItemFn};

#[proc_macro_attribute]
pub fn my_attribute(args: TokenStream, input: TokenStream) -> TokenStream {
    let args = parse_macro_input!(args as AttributeArgs);
    let input = parse_macro_input!(input as ItemFn);

    /* ... */
}