mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 21:42:34 +00:00
tiny changes to rustical_xml
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
use core::panic;
|
use core::panic;
|
||||||
use syn::{parse_macro_input, DeriveInput};
|
use syn::{DeriveInput, parse_macro_input};
|
||||||
|
|
||||||
pub(crate) mod attrs;
|
pub(crate) mod attrs;
|
||||||
mod common;
|
|
||||||
mod field;
|
mod field;
|
||||||
|
mod generic;
|
||||||
mod variant;
|
mod variant;
|
||||||
mod xml_enum;
|
mod xml_enum;
|
||||||
mod xml_struct;
|
mod xml_struct;
|
||||||
|
|
||||||
pub(crate) use common::*;
|
|
||||||
pub(crate) use field::Field;
|
pub(crate) use field::Field;
|
||||||
|
pub(crate) use generic::*;
|
||||||
pub(crate) use variant::Variant;
|
pub(crate) use variant::Variant;
|
||||||
pub(crate) use xml_enum::Enum;
|
pub(crate) use xml_enum::Enum;
|
||||||
pub(crate) use xml_struct::NamedStruct;
|
pub(crate) use xml_struct::NamedStruct;
|
||||||
|
|||||||
@@ -19,36 +19,27 @@ impl NamedStruct {
|
|||||||
pub fn parse(input: &DeriveInput, data: &DataStruct) -> Self {
|
pub fn parse(input: &DeriveInput, data: &DataStruct) -> Self {
|
||||||
let attrs = StructAttrs::from_derive_input(input).unwrap();
|
let attrs = StructAttrs::from_derive_input(input).unwrap();
|
||||||
|
|
||||||
match &data.fields {
|
let fields = match &data.fields {
|
||||||
syn::Fields::Named(named) => NamedStruct {
|
syn::Fields::Named(named) => named
|
||||||
fields: named
|
.named
|
||||||
.named
|
.iter()
|
||||||
.iter()
|
.enumerate()
|
||||||
.enumerate()
|
.map(|(i, field)| Field::from_syn_field(field.to_owned(), i))
|
||||||
.map(|(i, field)| Field::from_syn_field(field.to_owned(), i))
|
.collect(),
|
||||||
.collect(),
|
syn::Fields::Unnamed(unnamed) => unnamed
|
||||||
attrs,
|
.unnamed
|
||||||
ident: input.ident.to_owned(),
|
.iter()
|
||||||
generics: input.generics.to_owned(),
|
.enumerate()
|
||||||
},
|
.map(|(i, field)| Field::from_syn_field(field.to_owned(), i))
|
||||||
syn::Fields::Unnamed(unnamed) => NamedStruct {
|
.collect(),
|
||||||
fields: unnamed
|
syn::Fields::Unit => vec![],
|
||||||
.unnamed
|
};
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(i, field)| Field::from_syn_field(field.to_owned(), i))
|
|
||||||
.collect(),
|
|
||||||
attrs,
|
|
||||||
ident: input.ident.to_owned(),
|
|
||||||
generics: input.generics.to_owned(),
|
|
||||||
},
|
|
||||||
|
|
||||||
syn::Fields::Unit => NamedStruct {
|
NamedStruct {
|
||||||
fields: vec![],
|
fields,
|
||||||
attrs,
|
attrs,
|
||||||
ident: input.ident.to_owned(),
|
ident: input.ident.to_owned(),
|
||||||
generics: input.generics.to_owned(),
|
generics: input.generics.to_owned(),
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,10 +175,7 @@ impl NamedStruct {
|
|||||||
Event::Decl(_) => { /* <?xml ... ?> ignore this */ }
|
Event::Decl(_) => { /* <?xml ... ?> ignore this */ }
|
||||||
Event::Comment(_) => { /* ignore */ }
|
Event::Comment(_) => { /* ignore */ }
|
||||||
Event::DocType(_) => { /* ignore */ }
|
Event::DocType(_) => { /* ignore */ }
|
||||||
Event::PI(_) => {
|
Event::PI(_) => { /* ignore */ }
|
||||||
// Error: not supported
|
|
||||||
return Err(XmlError::UnsupportedEvent("Processing instruction"));
|
|
||||||
}
|
|
||||||
Event::End(end) => {
|
Event::End(end) => {
|
||||||
unreachable!("Unexpected closing tag for wrong element, should be handled by quick_xml");
|
unreachable!("Unexpected closing tag for wrong element, should be handled by quick_xml");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user