From 2267863ae7b14f3f879e5e5ffee17471accf4cd5 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Sun, 4 Sep 2022 15:38:41 +0200 Subject: [PATCH] Inline single-use method check_close_tag() --- instant-xml/src/de.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) 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> {