syn icon indicating copy to clipboard operation
syn copied to clipboard

Document how to parse NestedMeta items from an Attribute

Open dtolnay opened this issue 5 years ago • 0 comments

For parsing the parenthesized part of an attribute like #[attribute(k = "v")], parse_macro_input!(args as AttributeArgs) works when attribute is the currently expanding macro, but if attribute is just an inert attribute being parsed by some other macro then it looks a bit different. We should document this case as an example on Attribute::parse_args_with. The code will end up containing something like:

let args = attr.parse_args_with(Punctuated::<NestedMeta, Token![,]>::parse_terminated)?;

dtolnay avatar Jun 29 '20 21:06 dtolnay