mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 23:38:19 +00:00
xml: Move XmlRoot implementation into dedicated derive macro
This commit is contained in:
@@ -2,7 +2,6 @@ use core::panic;
|
||||
use syn::{parse_macro_input, DeriveInput};
|
||||
|
||||
mod de;
|
||||
|
||||
use de::{impl_de_enum, NamedStruct};
|
||||
|
||||
#[proc_macro_derive(XmlDeserialize, attributes(xml))]
|
||||
@@ -16,3 +15,15 @@ pub fn derive_xml_deserialize(input: proc_macro::TokenStream) -> proc_macro::Tok
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[proc_macro_derive(XmlRoot, attributes(xml))]
|
||||
pub fn derive_xml_root(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let input = parse_macro_input!(input as DeriveInput);
|
||||
|
||||
match &input.data {
|
||||
syn::Data::Struct(s) => NamedStruct::parse(&input, s).impl_xml_root(),
|
||||
syn::Data::Enum(_) => panic!("Enum not supported as root"),
|
||||
syn::Data::Union(_) => panic!("Union not supported as root"),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user