Simplify deserializer token stream

This commit is contained in:
Dirkjan Ochtman 2022-09-06 23:24:53 +02:00
parent 6c0cb83189
commit 4b0d5a7698
1 changed files with 85 additions and 92 deletions

View File

@ -106,8 +106,8 @@ impl Deserializer {
let attr_type_match = attributes_tokens.match_; let attr_type_match = attributes_tokens.match_;
let name = ident.to_string(); let name = ident.to_string();
let mut out = TokenStream::new(); let out = quote!(
out.extend(quote!( impl #xml_impl_generics FromXml<'xml> for #ident #ty_generics #where_clause {
fn deserialize<'cx>(deserializer: &'cx mut ::instant_xml::Deserializer<'cx, 'xml>) -> Result<Self, ::instant_xml::Error> { fn deserialize<'cx>(deserializer: &'cx mut ::instant_xml::Deserializer<'cx, 'xml>) -> Result<Self, ::instant_xml::Error> {
use ::instant_xml::de::{Deserializer, Id, Visitor, Node}; use ::instant_xml::de::{Deserializer, Id, Visitor, Node};
use ::instant_xml::Error; use ::instant_xml::Error;
@ -187,18 +187,11 @@ impl Deserializer {
StructVisitor::visit_struct(deserializer) StructVisitor::visit_struct(deserializer)
} }
));
out.extend(quote!(
const KIND: ::instant_xml::de::Kind = ::instant_xml::de::Kind::Element(::instant_xml::de::Id { const KIND: ::instant_xml::de::Kind = ::instant_xml::de::Kind::Element(::instant_xml::de::Id {
ns: #default_namespace, ns: #default_namespace,
name: #name, name: #name,
}); });
));
out = quote!(
impl #xml_impl_generics FromXml<'xml> for #ident #ty_generics #where_clause {
#out
} }
); );