diff --git a/src/attribute.rs b/src/attribute.rs index 1b9938cd..4c8f356c 100644 --- a/src/attribute.rs +++ b/src/attribute.rs @@ -1,5 +1,4 @@ //! Contains XML attributes manipulation types and functions. -//! use std::fmt; @@ -69,10 +68,7 @@ impl OwnedAttribute { /// Creates a new owned attribute using the provided owned name and an owned string value. #[inline] pub fn new>(name: OwnedName, value: S) -> Self { - Self { - name, - value: value.into(), - } + Self { name, value: value.into() } } } diff --git a/src/lib.rs b/src/lib.rs index d813f92b..4a0dfed5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,6 @@ //! //! Please note that functions of this parser may panic. //! If a panic could cause a Denial Of Service in your codebase, *you're* responsible for wrapping access to this library in `catch_unwind`. -//! #![cfg_attr(doctest, doc = include_str!("../README.md"))] diff --git a/src/name.rs b/src/name.rs index 89006ecf..66a7133c 100644 --- a/src/name.rs +++ b/src/name.rs @@ -1,5 +1,4 @@ //! Contains XML qualified names manipulation types and functions. -//! use std::fmt; use std::str::FromStr; diff --git a/src/reader/events.rs b/src/reader/events.rs index 2a2703d0..fff801b0 100644 --- a/src/reader/events.rs +++ b/src/reader/events.rs @@ -158,9 +158,9 @@ impl XmlEvent { /// ```rust /// use std::str; /// - /// use xml::{EventReader, EventWriter}; /// use xml::reader::XmlEvent as ReaderEvent; /// use xml::writer::XmlEvent as WriterEvent; + /// use xml::{EventReader, EventWriter}; /// /// let mut input: &[u8] = b"world"; /// let mut output: Vec = Vec::new(); diff --git a/src/reader/lexer.rs b/src/reader/lexer.rs index e2058f4d..bcff4ce3 100644 --- a/src/reader/lexer.rs +++ b/src/reader/lexer.rs @@ -422,7 +422,7 @@ impl Lexer { self.reparse_depth += 1; if self.reparse_depth > self.max_entity_expansion_depth || self.char_queue.len() > self.max_entity_expansion_length { - return Err(self.error(SyntaxError::EntityTooBig)) + return Err(self.error(SyntaxError::EntityTooBig)); } self.eof_handled = false; @@ -1136,8 +1136,6 @@ mod tests { check_case!(" { // Forward pos to the lexer head self.next_pos(); - return self.handle_eof() + return self.handle_eof(); }, - Ok(token) => { - match self.dispatch_token(token) { - None => continue, - Some(Ok(xml_event)) => { - self.next_pos(); - return Ok(xml_event); - }, - Some(Err(xml_error)) => { - self.next_pos(); - return self.set_final_result(Err(xml_error)); - }, - } + Ok(token) => match self.dispatch_token(token) { + None => continue, + Some(Ok(xml_event)) => { + self.next_pos(); + return Ok(xml_event); + }, + Some(Err(xml_error)) => { + self.next_pos(); + return self.set_final_result(Err(xml_error)); + }, }, Err(lexer_error) => { self.next_pos(); - return self.set_final_result(Err(lexer_error)) + return self.set_final_result(Err(lexer_error)); }, } } diff --git a/src/reader/parser/inside_closing_tag_name.rs b/src/reader/parser/inside_closing_tag_name.rs index 26c1ffec..12952871 100644 --- a/src/reader/parser/inside_closing_tag_name.rs +++ b/src/reader/parser/inside_closing_tag_name.rs @@ -17,16 +17,16 @@ impl PullParser { match token { Token::TagEnd => this.emit_end_element(), Token::Character(c) if is_whitespace_char(c) => this.into_state_continue(State::InsideClosingTag(ClosingTagSubstate::CTAfterName)), - _ => Some(this.error(SyntaxError::UnexpectedTokenInClosingTag(token))) + _ => Some(this.error(SyntaxError::UnexpectedTokenInClosingTag(token))), } } } }), ClosingTagSubstate::CTAfterName => match t { Token::TagEnd => self.emit_end_element(), - Token::Character(c) if is_whitespace_char(c) => None, // Skip whitespace - _ => Some(self.error(SyntaxError::UnexpectedTokenInClosingTag(t))) - } + Token::Character(c) if is_whitespace_char(c) => None, // Skip whitespace + _ => Some(self.error(SyntaxError::UnexpectedTokenInClosingTag(t))), + }, } } } diff --git a/src/reader/parser/inside_opening_tag.rs b/src/reader/parser/inside_opening_tag.rs index fc026508..6f0ac181 100644 --- a/src/reader/parser/inside_opening_tag.rs +++ b/src/reader/parser/inside_opening_tag.rs @@ -83,7 +83,7 @@ impl PullParser { this.nst.put(name.local_name.clone(), value); this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::AfterAttributeValue)) } - } + }, // declaring default namespace None if &*name.local_name == namespace::NS_XMLNS_PREFIX => @@ -101,12 +101,9 @@ impl PullParser { if this.data.attributes.len() >= max_attrs { return Some(this.error(SyntaxError::ExceededConfiguredLimit)); } - this.data.attributes.push(OwnedAttribute { - name, - value - }); + this.data.attributes.push(OwnedAttribute { name, value }); this.into_state_continue(State::InsideOpeningTag(OpeningTagSubstate::AfterAttributeValue)) - } + }, } }), diff --git a/src/reader/parser/inside_processing_instruction.rs b/src/reader/parser/inside_processing_instruction.rs index 884abf26..836b3e02 100644 --- a/src/reader/parser/inside_processing_instruction.rs +++ b/src/reader/parser/inside_processing_instruction.rs @@ -75,7 +75,7 @@ impl PullParser { // can't have a PI before ` Ok(c), Some(_) if self.config.c.replace_unknown_entity_references => Ok('\u{fffd}'), - None if self.config.c.replace_unknown_entity_references => { - Ok('\u{fffd}') - }, + None if self.config.c.replace_unknown_entity_references => Ok('\u{fffd}'), _ => Err(SyntaxError::InvalidCharacterEntity(val)), } } diff --git a/src/util.rs b/src/util.rs index ed4839f4..090d2cdf 100644 --- a/src/util.rs +++ b/src/util.rs @@ -103,9 +103,7 @@ pub(crate) struct CharReader { impl CharReader { pub const fn new() -> Self { - Self { - encoding: Encoding::Unknown, - } + Self { encoding: Encoding::Unknown } } pub fn next_char_from(&mut self, source: &mut R) -> Result, CharReadError> { diff --git a/src/writer/emitter.rs b/src/writer/emitter.rs index 765535df..2cdf2e7c 100644 --- a/src/writer/emitter.rs +++ b/src/writer/emitter.rs @@ -317,7 +317,7 @@ impl Emitter { write!(target, " xmlns=\"{uri}\"") } else { Ok(()) }, // everything else - prefix => write!(target, " xmlns:{prefix}=\"{uri}\"") + prefix => write!(target, " xmlns:{prefix}=\"{uri}\""), }?; } Ok(()) diff --git a/src/writer/events.rs b/src/writer/events.rs index c6ded060..cc087047 100644 --- a/src/writer/events.rs +++ b/src/writer/events.rs @@ -207,8 +207,7 @@ impl<'a> StartElementBuilder<'a> { #[inline] #[must_use] pub fn attr(mut self, name: N, value: &'a str) -> Self - where N: Into> - { + where N: Into> { self.attributes.push(Attribute::new(name.into(), value)); self } @@ -240,8 +239,7 @@ impl<'a> StartElementBuilder<'a> { #[inline] #[must_use] pub fn default_ns(mut self, uri: S) -> Self - where S: Into - { + where S: Into { self.namespace.put(NS_NO_PREFIX, uri); self } diff --git a/tests/event_reader.rs b/tests/event_reader.rs index 9c645739..920e6a4f 100644 --- a/tests/event_reader.rs +++ b/tests/event_reader.rs @@ -887,16 +887,11 @@ impl<'a> fmt::Display for Event<'a> { write!(f, "StartElement({} [{}])", Name(name), attrs.join(", ")) } }, - XmlEvent::EndElement { ref name } => - write!(f, "EndElement({})", Name(name)), - XmlEvent::Comment(ref data) => - write!(f, r#"Comment("{}")"#, data.escape_debug()), - XmlEvent::CData(ref data) => - write!(f, r#"CData("{}")"#, data.escape_debug()), - XmlEvent::Characters(ref data) => - write!(f, r#"Characters("{}")"#, data.escape_debug()), - XmlEvent::Whitespace(ref data) => - write!(f, r#"Whitespace("{}")"#, data.escape_debug()), + XmlEvent::EndElement { ref name } => write!(f, "EndElement({})", Name(name)), + XmlEvent::Comment(ref data) => write!(f, r#"Comment("{}")"#, data.escape_debug()), + XmlEvent::CData(ref data) => write!(f, r#"CData("{}")"#, data.escape_debug()), + XmlEvent::Characters(ref data) => write!(f, r#"Characters("{}")"#, data.escape_debug()), + XmlEvent::Whitespace(ref data) => write!(f, r#"Whitespace("{}")"#, data.escape_debug()), }, Err(ref e) => e.fmt(f), } diff --git a/tests/streaming.rs b/tests/streaming.rs index f03995c2..a0b2a014 100644 --- a/tests/streaming.rs +++ b/tests/streaming.rs @@ -90,8 +90,8 @@ fn reading_streamed_content2() { match reader.next() { None | Some(Ok(_)) => { panic!("At this point, parser must not detect something."); - } - Some(Err(_)) => {} + }, + Some(Err(_)) => {}, }; write_and_reset_position(reader.source_mut(), b" />"); assert_match!(reader.next(), Some(Ok(XmlEvent::StartElement { ref name, .. })) if name.local_name == "child-4"); diff --git a/tests/xmlconf.rs b/tests/xmlconf.rs index f8dd58fe..1784d6db 100644 --- a/tests/xmlconf.rs +++ b/tests/xmlconf.rs @@ -116,7 +116,7 @@ fn expect_well_formed(xml_path: &Path, msg: &str) -> Result<(), Box { if document_started { return Err("document started twice".into()); } document_started = true; - } + }, _ => {}, } if let Some(e) = e.as_writer_event() { @@ -125,7 +125,9 @@ fn expect_well_formed(xml_path: &Path, msg: &str) -> Result<(), Box