mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-17 06:29:30 +00:00
xml: Also implement unit variants
This commit is contained in:
@@ -67,9 +67,21 @@ pub fn derive_enum_variants(input: proc_macro::TokenStream) -> proc_macro::Token
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
match &input.data {
|
||||
syn::Data::Struct(_) => panic!("Struct not supported, use XmlRootTag instead"),
|
||||
syn::Data::Struct(_) => panic!("Struct not supported"),
|
||||
syn::Data::Enum(e) => Enum::parse(&input, e).impl_enum_variants(),
|
||||
syn::Data::Union(_) => panic!("Union not supported as root"),
|
||||
syn::Data::Union(_) => panic!("Union not supported"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(EnumUnitVariants, attributes(xml))]
|
||||
pub fn derive_enum_unit_variants(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
match &input.data {
|
||||
syn::Data::Struct(_) => panic!("Struct not supported"),
|
||||
syn::Data::Enum(e) => Enum::parse(&input, e).impl_enum_unit_variants(),
|
||||
syn::Data::Union(_) => panic!("Union not supported"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user