mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 23:38:19 +00:00
xml: Implement XmlDocument for tagged enums and fix small bug
This commit is contained in:
@@ -39,3 +39,15 @@ pub fn derive_xml_root_tag(input: proc_macro::TokenStream) -> proc_macro::TokenS
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(XmlDocument, attributes(xml))]
|
||||
pub fn derive_xml_document(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, use XmlRootTag instead"),
|
||||
syn::Data::Enum(e) => Enum::parse(&input, e).impl_xml_document(),
|
||||
syn::Data::Union(_) => panic!("Union not supported as root"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user