macro_rules! convert_parsed_from_meta_list {
($ty:ty) => { ... };
}Expand description
Implement the ConvertParsed<Type = syn::MetaList> trait for the type.
Requires that the type has implemented the FromAttr and AttributeIdent traits.
Generally used for parsing nested attributes.
ยงExample
use from_attr::{FromAttr, convert_parsed_from_meta_list};
use syn::parse_quote;
#[derive(FromAttr, PartialEq, Eq, Debug)]
#[attribute(idents = [inner])]
struct Inner {
a: usize,
}
convert_parsed_from_meta_list!(Inner);
#[derive(FromAttr, PartialEq, Eq, Debug)]
#[attribute(idents = [outer])]
struct Outer {
a: usize,
b: Inner,
}
let attrs = [parse_quote!(#[outer(a = 1, b = inner(a = 10))])];
assert_eq!(
Outer::from_attributes(&attrs).unwrap().unwrap().value,
Outer {
a: 1,
b: Inner { a: 10 }
}
);