diff --git a/instant-xml/src/de.rs b/instant-xml/src/de.rs index 8d184fa..927df06 100644 --- a/instant-xml/src/de.rs +++ b/instant-xml/src/de.rs @@ -119,7 +119,15 @@ impl<'xml> Deserializer<'xml> { let ret = visitor.visit_struct(self)?; // Process close tag - self.check_close_tag(name)?; + let item = match self.parser.next() { + Some(item) => item?, + None => return Err(Error::MissingTag), + }; + + match item { + XmlRecord::Close(v) if v == name => {} + _ => return Err(Error::UnexpectedTag), + } // Removing parser namespaces let _ = new_parser_namespaces @@ -202,18 +210,6 @@ impl<'xml> Deserializer<'xml> { None => Err(Error::UnexpectedEndOfStream), } } - - fn check_close_tag(&mut self, name: &str) -> Result<(), Error> { - let item = match self.parser.next() { - Some(item) => item?, - None => return Err(Error::MissingTag), - }; - - match item { - XmlRecord::Close(v) if v == name => Ok(()), - _ => Err(Error::UnexpectedTag), - } - } } pub struct XmlParser<'xml> {