-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hey!
Is it possible to create nested attribute structs? I was thinking something like:
use structmeta::StructMeta;
use syn::{Attribute, LitStr};
struct CommonAttrs {
foo: LitStr,
bar: LitStr,
}
#[derive(StructMeta)]
struct Attrs {
common: CommonAttrs,
baz: LitStr,
}
fn parse(attrs: Vec<Attribute>) {
for attr in attrs {
if !attr.path.is_ident("my_macro") {
continue;
}
struct_attrs = attr.parse_args::<Attrs>()?;
}
}
With the following macro:
#[derive(MyMacro)]
#[my_macro(foo = "foo", bar = "bar", baz = "baz")]
struct Data {}
This would allow one to extract common attributes without maintaining different attribute structs with the same common fields. Let me know if that's possible and, if not, if this is planned for the future. Thx!
Metadata
Metadata
Assignees
Labels
No labels