[][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:

# const IGNORE: &str = stringify! {
#[my_attribute(path = "/v1/refresh")]
# };
pub fn refresh() {
    /* ... */
}

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

extern crate proc_macro;

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

# const IGNORE: &str = stringify! {
#[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);

    /* ... */
#   "".parse().unwrap()
}