diff --git a/Cargo.toml b/Cargo.toml index cedf048f9..5c25b9bf8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "quick-xml" -version = "0.41.0" +version = "0.42.0" description = "High performance xml reader and writer" -edition = "2021" +edition = "2024" documentation = "https://docs.rs/quick-xml" repository = "https://github.com/tafia/quick-xml" diff --git a/Changelog.md b/Changelog.md index 99204828f..a0a9470f9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -14,12 +14,24 @@ ## Unreleased +### Breaking Changes + +### New Features + +### Bug Fixes + +### Misc Changes + + +## 0.42.0 -- 2026-08-22 + This is a large release. The primary change is an ergonomic improvement across the entire API - quick_xml now makes use of `&str` and `String` types where possible instead of `&[u8]` and `Vec`. This requires significant refactoring of downstream code, -but should result in a net simplification as well as potential performance improvements. +but should result in a net simplification as well as potential performance improvements, +and opens up additional opportunities in future releases. -The MSRV has been raised to 1.86. +The MSRV has been raised to 1.86. We now use Rust 2024 Edition. ### Breaking Changes diff --git a/benches/encoding.rs b/benches/encoding.rs index e4b3578c2..f511a06de 100644 --- a/benches/encoding.rs +++ b/benches/encoding.rs @@ -1,4 +1,4 @@ -use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; +use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; use pretty_assertions::assert_eq; use std::io::{BufReader, Read}; diff --git a/benches/issue971.rs b/benches/issue971.rs index 80246eb58..6d247a401 100644 --- a/benches/issue971.rs +++ b/benches/issue971.rs @@ -14,7 +14,7 @@ //! [#969]: https://github.com/tafia/quick-xml/issues/969 //! [#971]: https://github.com/tafia/quick-xml/pull/971 -use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput}; +use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; use quick_xml::events::Event; use quick_xml::reader::Reader; diff --git a/benches/macrobenches.rs b/benches/macrobenches.rs index 3988391b0..1f53001fe 100644 --- a/benches/macrobenches.rs +++ b/benches/macrobenches.rs @@ -1,4 +1,4 @@ -use criterion::{self, criterion_group, criterion_main, Criterion, Throughput}; +use criterion::{self, Criterion, Throughput, criterion_group, criterion_main}; use quick_xml::events::Event; use quick_xml::reader::{NsReader, Reader}; use quick_xml::{Result as XmlResult, XmlVersion}; diff --git a/benches/microbenches.rs b/benches/microbenches.rs index 76951ee26..f0d887a32 100644 --- a/benches/microbenches.rs +++ b/benches/microbenches.rs @@ -1,4 +1,4 @@ -use criterion::{self, criterion_group, criterion_main, Criterion}; +use criterion::{self, Criterion, criterion_group, criterion_main}; use pretty_assertions::assert_eq; use quick_xml::escape::{escape, unescape}; use quick_xml::events::Event; @@ -231,10 +231,11 @@ fn attributes(c: &mut Criterion) { count += 1 } } - assert!(e - .try_get_attribute("attribute-that-doesn't-exist") - .unwrap() - .is_none()); + assert!( + e.try_get_attribute("attribute-that-doesn't-exist") + .unwrap() + .is_none() + ); } Ok(Event::Eof) => break, _ => (), diff --git a/examples/custom_entities.rs b/examples/custom_entities.rs index 061c3b44d..0399cff5f 100644 --- a/examples/custom_entities.rs +++ b/examples/custom_entities.rs @@ -13,12 +13,12 @@ use std::borrow::Cow; use std::collections::{HashMap, VecDeque}; +use quick_xml::XmlVersion; use quick_xml::errors::Error; use quick_xml::escape::EscapeError; use quick_xml::events::{BytesEnd, BytesStart, BytesText, Event}; use quick_xml::name::QName; use quick_xml::reader::Reader; -use quick_xml::XmlVersion; use regex::Regex; use pretty_assertions::assert_eq; diff --git a/examples/getting_started.rs b/examples/getting_started.rs index 23058f163..00010a957 100644 --- a/examples/getting_started.rs +++ b/examples/getting_started.rs @@ -26,9 +26,9 @@ //! - `writer.rs` for producing XML //! - `examples/README.md` for a guide on which approach to choose +use quick_xml::XmlVersion; use quick_xml::events::Event; use quick_xml::reader::Reader; -use quick_xml::XmlVersion; const XML: &str = r#" diff --git a/examples/read_nodes.rs b/examples/read_nodes.rs index 31b39d89f..a0707ca06 100644 --- a/examples/read_nodes.rs +++ b/examples/read_nodes.rs @@ -2,12 +2,12 @@ // Note: for this specific data set using serde feature would simplify // this simple data is purely to make it easier to understand the code +use quick_xml::XmlVersion; use quick_xml::encoding::EncodingError; use quick_xml::events::attributes::AttrError; use quick_xml::events::{BytesStart, Event}; use quick_xml::name::QName; use quick_xml::reader::Reader; -use quick_xml::XmlVersion; use std::borrow::Cow; use std::collections::HashMap; use std::convert::Infallible; diff --git a/examples/read_utf16.rs b/examples/read_utf16.rs index e64b91acf..87e03c6be 100644 --- a/examples/read_utf16.rs +++ b/examples/read_utf16.rs @@ -6,10 +6,10 @@ fn main() -> Result<(), quick_xml::Error> { use std::fs::File; use std::io::BufReader; + use quick_xml::XmlVersion; use quick_xml::encoding::DecodingReader; use quick_xml::events::Event; use quick_xml::reader::Reader; - use quick_xml::XmlVersion; let file = File::open("tests/documents/encoding/utf16le-bom.xml")?; let transcoder = DecodingReader::new(BufReader::new(file)); diff --git a/examples/reader_patterns.rs b/examples/reader_patterns.rs index 398cd883a..5470ba717 100644 --- a/examples/reader_patterns.rs +++ b/examples/reader_patterns.rs @@ -33,9 +33,9 @@ //! cargo run --example reader_patterns //! ``` +use quick_xml::XmlVersion; use quick_xml::events::{BytesStart, Event}; use quick_xml::reader::Reader; -use quick_xml::XmlVersion; const XML: &str = r#" diff --git a/examples/serde_roundtrip.rs b/examples/serde_roundtrip.rs index 42297c6b9..9edda2ec2 100644 --- a/examples/serde_roundtrip.rs +++ b/examples/serde_roundtrip.rs @@ -15,11 +15,14 @@ //! |------------------------------|----------------------------------------------| //! | attribute `id="..."` | `#[serde(rename = "@id")]` | //! | text inside an element | `#[serde(rename = "$text")]` | +//! | xs:choice as Rust enum | `#[serde(rename = "$value")]` | //! | fields shared across types | `#[serde(flatten)]` on a sub-struct | //! | child element `` | a field named `title` (no prefix) | //! | repeated child elements | a `Vec<T>` field | //! | the element's own tag name | chosen by the parent field / root, see below | //! +//! See [`Mapping XML to Rust types`] for more info. +//! //! Types are converted for you: `available="true"` becomes a `bool`, //! `<price>39.95</price>` becomes an `f64`, and so on. //! @@ -28,6 +31,8 @@ //! ```console //! cargo run --example serde_roundtrip --features serialize //! ``` +//! +//! [`Mapping XML to Rust types`]: https://docs.rs/quick-xml/latest/quick_xml/de/index.html#mapping-xml-to-rust-types use quick_xml::de::from_str; use quick_xml::events::{BytesEnd, BytesStart, Event}; diff --git a/examples/visitor.rs b/examples/visitor.rs index f2a18dd9c..5247f59b1 100644 --- a/examples/visitor.rs +++ b/examples/visitor.rs @@ -35,9 +35,9 @@ //! cargo run --example visitor //! ``` +use quick_xml::XmlVersion; use quick_xml::events::{BytesStart, Event}; use quick_xml::reader::Reader; -use quick_xml::XmlVersion; const XML: &str = r#"<?xml version="1.0" encoding="UTF-8"?> <catalog> diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index db4f488c8..c40d7e659 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -3,7 +3,7 @@ name = "quick-xml-fuzz" version = "0.0.0" authors = ["Automatically generated"] publish = false -edition = "2021" +edition = "2024" [package.metadata] cargo-fuzz = true diff --git a/src/de/attributes.rs b/src/de/attributes.rs index 10b17ceac..21acc8e9e 100644 --- a/src/de/attributes.rs +++ b/src/de/attributes.rs @@ -5,11 +5,11 @@ use std::borrow::Cow; use serde::de::{DeserializeSeed, Deserializer, Error, MapAccess, Visitor}; use serde::forward_to_deserialize_any; -use crate::de::key::QNameDeserializer; +use crate::XmlVersion; use crate::de::SimpleTypeDeserializer; +use crate::de::key::QNameDeserializer; use crate::errors::serialize::DeError; use crate::events::attributes::Attributes; -use crate::XmlVersion; impl<'i> Attributes<'i> { /// Converts this iterator into a serde's [`MapAccess`] trait to use with serde. diff --git a/src/de/map.rs b/src/de/map.rs index 63a142263..e1c4bcab6 100644 --- a/src/de/map.rs +++ b/src/de/map.rs @@ -5,11 +5,11 @@ use crate::{ de::resolver::EntityResolver, de::simple_type::SimpleTypeDeserializer, de::text::TextDeserializer, - de::{DeEvent, Deserializer, XmlRead, TEXT_KEY, VALUE_KEY}, - errors::serialize::DeError, + de::{DeEvent, Deserializer, TEXT_KEY, VALUE_KEY, XmlRead}, errors::Error, - events::attributes::IterState, + errors::serialize::DeError, events::BytesStart, + events::attributes::IterState, name::QName, }; use serde::de::value::BorrowedStrDeserializer; diff --git a/src/de/mod.rs b/src/de/mod.rs index 51cc48853..f6786f7bf 100644 --- a/src/de/mod.rs +++ b/src/de/mod.rs @@ -2106,13 +2106,13 @@ mod var; pub use self::attributes::AttributesDeserializer; pub use self::resolver::{EntityResolver, PredefinedEntityResolver}; pub use self::simple_type::SimpleTypeDeserializer; -pub use crate::errors::serialize::DeError; use crate::XmlVersion; +pub use crate::errors::serialize::DeError; use crate::{ de::map::ElementMapAccess, errors::Error, - escape::{parse_number, EscapeError}, + escape::{EscapeError, parse_number}, events::{BytesCData, BytesEnd, BytesRef, BytesStart, BytesText, Event}, name::{NamespaceResolver, QName}, reader::{NsReader, Reader}, diff --git a/src/de/simple_type.rs b/src/de/simple_type.rs index a703e0b17..a6da474ee 100644 --- a/src/de/simple_type.rs +++ b/src/de/simple_type.rs @@ -3,11 +3,11 @@ //! [simple types]: https://www.w3schools.com/xml/el_simpletype.asp //! [as defined]: https://www.w3.org/TR/xmlschema11-1/#Simple_Type_Definition +use crate::XmlVersion; use crate::de::Text; use crate::errors::serialize::DeError; use crate::escape::resolve_predefined_entity; -use crate::utils::{trim_xml_spaces, CowRef}; -use crate::XmlVersion; +use crate::utils::{CowRef, trim_xml_spaces}; use memchr::memchr; use serde::de::value::UnitDeserializer; use serde::de::{ @@ -741,8 +741,8 @@ impl<'de, 'a> IntoDeserializer<'de, DeError> for SimpleTypeDeserializer<'de, 'a> #[cfg(test)] mod tests { use super::*; - use crate::se::simple_type::{QuoteTarget, SimpleTypeSerializer}; use crate::se::QuoteLevel; + use crate::se::simple_type::{QuoteTarget, SimpleTypeSerializer}; use crate::utils::{ByteBuf, Bytes}; use serde::de::IgnoredAny; use serde::{Deserialize, Serialize}; diff --git a/src/de/text.rs b/src/de/text.rs index 5333f7a44..86b3f2751 100644 --- a/src/de/text.rs +++ b/src/de/text.rs @@ -1,6 +1,6 @@ use crate::{ de::simple_type::SimpleTypeDeserializer, - de::{Text, TEXT_KEY}, + de::{TEXT_KEY, Text}, errors::serialize::DeError, }; use serde::de::value::BorrowedStrDeserializer; diff --git a/src/de/var.rs b/src/de/var.rs index b55441299..64bc2a0b9 100644 --- a/src/de/var.rs +++ b/src/de/var.rs @@ -3,7 +3,7 @@ use crate::{ de::map::ElementMapAccess, de::resolver::EntityResolver, de::simple_type::SimpleTypeDeserializer, - de::{DeEvent, Deserializer, XmlRead, TEXT_KEY}, + de::{DeEvent, Deserializer, TEXT_KEY, XmlRead}, errors::serialize::DeError, }; use serde::de::value::BorrowedStrDeserializer; diff --git a/src/errors.rs b/src/errors.rs index 0982f4480..8ed233a4a 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -152,7 +152,11 @@ impl fmt::Display for IllFormedError { f.write_str("an XML declaration does not contain `version` attribute") } Self::MissingDeclVersion(Some(attr)) => { - write!(f, "an XML declaration must start with `version` attribute, but in starts with `{}`", attr) + write!( + f, + "an XML declaration must start with `version` attribute, but in starts with `{}`", + attr + ) } Self::UnknownVersion => { f.write_str("unknown XML version: either 1.0 or 1.1 is expected") diff --git a/src/events/attributes.rs b/src/events/attributes.rs index 39f9f5db3..45dd2a9c9 100644 --- a/src/events/attributes.rs +++ b/src/events/attributes.rs @@ -2,12 +2,12 @@ //! //! Provides an iterator over attributes key/value pairs +use crate::XmlVersion; use crate::encoding::Decoder; use crate::errors::Result as XmlResult; use crate::escape::{escape_attribute, resolve_predefined_entity}; use crate::name::{LocalName, Namespace, NamespaceResolver, QName}; use crate::utils::is_whitespace; -use crate::XmlVersion; use std::collections::HashSet; use std::fmt::{self, Debug, Display, Formatter}; @@ -967,7 +967,7 @@ impl IterState { fn skip_value(&self, slice: &[u8], offset: usize) -> Option<usize> { let mut iter = (offset..).zip(slice[offset..].iter()); - match iter.find(|(_, &b)| is_whitespace(b)) { + match iter.find(|&(_, &b)| is_whitespace(b)) { // Input: ` key = value ` // | ^ // offset e @@ -985,7 +985,7 @@ impl IterState { let mut iter = (offset..).zip(slice[offset..].iter()); // Skip all up to the quote and get the quote type - let quote = match iter.find(|(_, &b)| !is_whitespace(b)) { + let quote = match iter.find(|&(_, &b)| !is_whitespace(b)) { // Input: ` key = "` // | ^ // offset @@ -1005,7 +1005,7 @@ impl IterState { None => return None, }; - match iter.find(|(_, &b)| b == quote) { + match iter.find(|&(_, &b)| b == quote) { // Input: ` key = " "` // ^ Some((e, b'"')) => Some(e), @@ -1127,7 +1127,7 @@ impl IterState { }; // Index where next key started - let start_key = match iter.find(|(_, &b)| !is_whitespace(b)) { + let start_key = match iter.find(|&(_, &b)| !is_whitespace(b)) { // Input: ` key` // ^ Some((s, _)) => s, @@ -1140,7 +1140,7 @@ impl IterState { } }; // Span of a key - let (key, offset) = match iter.find(|(_, &b)| b == b'=' || is_whitespace(b)) { + let (key, offset) = match iter.find(|&(_, &b)| b == b'=' || is_whitespace(b)) { // Input: ` key=` // | ^ // s e @@ -1148,7 +1148,7 @@ impl IterState { // Input: ` key ` // ^ - Some((e, _)) => match iter.find(|(_, &b)| !is_whitespace(b)) { + Some((e, _)) => match iter.find(|&(_, &b)| !is_whitespace(b)) { // Input: ` key =` // | | ^ // start_key e @@ -1196,7 +1196,7 @@ impl IterState { //////////////////////////////////////////////////////////////////////// // Gets the position of quote and quote type - let (start_value, quote) = match iter.find(|(_, &b)| !is_whitespace(b)) { + let (start_value, quote) = match iter.find(|&(_, &b)| !is_whitespace(b)) { // Input: ` key = "` // ^ Some((s, b'"')) => (s + 1, b'"'), @@ -1211,7 +1211,7 @@ impl IterState { // We do not check validity of attribute value characters as required // according to https://html.spec.whatwg.org/#unquoted. It can be done // during validation phase - let end = match iter.find(|(_, &b)| is_whitespace(b)) { + let end = match iter.find(|&(_, &b)| is_whitespace(b)) { // Input: ` key = value ` // | ^ // s e @@ -1240,7 +1240,7 @@ impl IterState { } }; - match iter.find(|(_, &b)| b == quote) { + match iter.find(|&(_, &b)| b == quote) { // Input: ` key = " "` // ^ Some((e, b'"')) => self.double_q(key, start_value..e), @@ -1296,9 +1296,9 @@ mod xml { mod attribute_value_normalization { use super::*; + use crate::XmlVersion::*; use crate::errors::Error; use crate::escape::EscapeError::*; - use crate::XmlVersion::*; use pretty_assertions::assert_eq; /// Empty values returned are unchanged diff --git a/src/events/mod.rs b/src/events/mod.rs index 81110cf08..9f010ea89 100644 --- a/src/events/mod.rs +++ b/src/events/mod.rs @@ -45,15 +45,15 @@ use std::iter::FusedIterator; use std::mem::replace; use std::ops::Deref; +use crate::XmlVersion; use crate::encoding::EncodingError; use crate::errors::{Error, IllFormedError}; use crate::escape::{ - escape, minimal_escape, normalize_xml10_eols, normalize_xml11_eols, parse_number, - partial_escape, EscapeError, + EscapeError, escape, minimal_escape, normalize_xml10_eols, normalize_xml11_eols, parse_number, + partial_escape, }; use crate::name::{LocalName, QName}; use crate::utils::{self, name_len, trim_xml_end, trim_xml_start, write_cow_string}; -use crate::XmlVersion; use attributes::{AttrError, Attribute, Attributes}; /// Opening tag data (`Event::Start`), with optional attributes: `<name attr="value">`. diff --git a/src/name.rs b/src/name.rs index e3dd1053f..d0aa49ed5 100644 --- a/src/name.rs +++ b/src/name.rs @@ -73,7 +73,11 @@ impl fmt::Display for NamespaceError { ) } Self::InvalidPrefixForXml(prefix) => { - write!(f, "the namespace prefix '{}' cannot be bound to 'http://www.w3.org/XML/1998/namespace'", prefix) + write!( + f, + "the namespace prefix '{}' cannot be bound to 'http://www.w3.org/XML/1998/namespace'", + prefix + ) } Self::InvalidPrefixForXmlns(prefix) => { write!( @@ -1281,8 +1285,8 @@ impl<'a> FusedIterator for NamespaceBindingsOfLevelIter<'a> {} #[cfg(test)] mod namespaces { use super::*; - use pretty_assertions::assert_eq; use ResolveResult::*; + use pretty_assertions::assert_eq; /// Regression test for <https://github.com/tafia/quick-xml/issues/970>: a single element with /// many `xmlns:*` declarations must be rejected once the total binding count exceeds the limit. diff --git a/src/parser/comment.rs b/src/parser/comment.rs index 7a755b333..c6e574aa8 100644 --- a/src/parser/comment.rs +++ b/src/parser/comment.rs @@ -143,8 +143,8 @@ fn seen2(bytes: &[u8]) -> Option<usize> { #[test] fn parse() { - use pretty_assertions::assert_eq; use CommentParser::*; + use pretty_assertions::assert_eq; /// Returns `Ok(pos)` with the position in the buffer where element is ended. /// diff --git a/src/parser/element.rs b/src/parser/element.rs index 1d78c9c55..33b295d26 100644 --- a/src/parser/element.rs +++ b/src/parser/element.rs @@ -91,8 +91,8 @@ impl Default for ElementParser { #[test] fn parse() { - use pretty_assertions::assert_eq; use ElementParser::*; + use pretty_assertions::assert_eq; /// Returns `Ok(pos)` with the position in the buffer where element is ended. /// diff --git a/src/reader/buffered_reader.rs b/src/reader/buffered_reader.rs index 571f8e63b..4b4990e10 100644 --- a/src/reader/buffered_reader.rs +++ b/src/reader/buffered_reader.rs @@ -601,8 +601,8 @@ impl Reader<BufReader<File>> { #[cfg(test)] mod test { - use crate::reader::test::check; use crate::reader::XmlSource; + use crate::reader::test::check; /// Default buffer constructor just pass the byte array from the test fn identity<T>(input: T) -> T { diff --git a/src/reader/mod.rs b/src/reader/mod.rs index bdf1f3bb0..aae0407db 100644 --- a/src/reader/mod.rs +++ b/src/reader/mod.rs @@ -1241,7 +1241,7 @@ impl BangType { } } } - Self::DocType(ref mut parser) => return parser.feed(buf, chunk), + Self::DocType(parser) => return parser.feed(buf, chunk), } None } diff --git a/src/reader/slice_reader.rs b/src/reader/slice_reader.rs index 6f5c2edef..fbbd869f4 100644 --- a/src/reader/slice_reader.rs +++ b/src/reader/slice_reader.rs @@ -425,8 +425,8 @@ impl<'a> XmlSource<'a, ()> for &'a [u8] { #[cfg(test)] mod test { - use crate::reader::test::check; use crate::reader::XmlSource; + use crate::reader::test::check; /// Default buffer constructor just pass the byte array from the test fn identity<T>(input: T) -> T { diff --git a/src/se/content.rs b/src/se/content.rs index 9d5c04421..ea5d85d62 100644 --- a/src/se/content.rs +++ b/src/se/content.rs @@ -482,9 +482,9 @@ impl<'w, 'i, W: Write> SerializeTupleStruct for Seq<'w, 'i, W> { pub(super) mod tests { use super::*; use crate::utils::Bytes; + use WriteResult::*; use serde::Serialize; use std::collections::BTreeMap; - use WriteResult::*; #[derive(Debug, Serialize, PartialEq)] pub struct Unit; diff --git a/src/se/mod.rs b/src/se/mod.rs index e76be984c..9db3ef408 100644 --- a/src/se/mod.rs +++ b/src/se/mod.rs @@ -524,7 +524,7 @@ impl<'i> Indent<'i> { pub fn borrow(&mut self) -> Indent<'_> { match self { Self::None => Indent::None, - Self::Owned(ref mut i) => Indent::Borrow(i), + Self::Owned(i) => Indent::Borrow(i), Self::Borrow(i) => Indent::Borrow(i), } } diff --git a/src/se/text.rs b/src/se/text.rs index 600e521a1..af365d2a4 100644 --- a/src/se/text.rs +++ b/src/se/text.rs @@ -1,8 +1,8 @@ //! Contains serializer for a special `&text` field use crate::de::TEXT_KEY; -use crate::se::simple_type::{SimpleSeq, SimpleTypeSerializer}; use crate::se::SeError; +use crate::se::simple_type::{SimpleSeq, SimpleTypeSerializer}; use serde::ser::{Impossible, Serialize, Serializer}; use std::fmt::Write; diff --git a/src/writer.rs b/src/writer.rs index 4affb6743..b6a7c32ae 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -4,7 +4,8 @@ use std::borrow::Cow; use std::io::{self, Write}; use crate::encoding::UTF8_BOM; -use crate::events::{attributes::Attribute, BytesCData, BytesPI, BytesStart, BytesText, Event}; +use crate::events::attributes::Attribute; +use crate::events::{BytesCData, BytesPI, BytesStart, BytesText, Event}; #[cfg(feature = "async-tokio")] mod async_tokio; diff --git a/test-gen/Cargo.toml b/test-gen/Cargo.toml index a6f5e0355..e9170a5e4 100644 --- a/test-gen/Cargo.toml +++ b/test-gen/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "test-gen" version = "0.1.0" -edition = "2021" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/tests/encodings.rs b/tests/encodings.rs index 4a5dfeb00..dffe189c1 100644 --- a/tests/encodings.rs +++ b/tests/encodings.rs @@ -1,4 +1,4 @@ -use encoding_rs::{UTF_16BE, UTF_16LE, UTF_8, WINDOWS_1251}; +use encoding_rs::{UTF_8, UTF_16BE, UTF_16LE, WINDOWS_1251}; use pretty_assertions::assert_eq; use quick_xml::events::Event::*; use quick_xml::reader::Reader; diff --git a/tests/escape.rs b/tests/escape.rs index b85853761..abd21c4ae 100644 --- a/tests/escape.rs +++ b/tests/escape.rs @@ -87,11 +87,15 @@ fn unescape() { #[test] fn unescape_long() { assert_eq!( - escape::unescape("0"), + escape::unescape( + "0" + ), Ok("0".into()), ); assert_eq!( - escape::unescape("0"), + escape::unescape( + "0" + ), Ok("0".into()), ); @@ -189,11 +193,17 @@ fn unescape_with() { #[test] fn unescape_with_long() { assert_eq!( - escape::unescape_with("0", |_| None), + escape::unescape_with( + "0", + |_| None + ), Ok("0".into()), ); assert_eq!( - escape::unescape_with("0", |_| None), + escape::unescape_with( + "0", + |_| None + ), Ok("0".into()), ); diff --git a/tests/fuzzing.rs b/tests/fuzzing.rs index 4d48eeeee..60e1b596a 100644 --- a/tests/fuzzing.rs +++ b/tests/fuzzing.rs @@ -1,9 +1,9 @@ //! Cases that was found by fuzzing +use quick_xml::XmlVersion; use quick_xml::errors::{Error, IllFormedError}; use quick_xml::events::Event; use quick_xml::reader::Reader; -use quick_xml::XmlVersion; #[test] fn fuzz_53() { diff --git a/tests/reader-namespaces.rs b/tests/reader-namespaces.rs index 144bc4a5c..6914a2983 100644 --- a/tests/reader-namespaces.rs +++ b/tests/reader-namespaces.rs @@ -1,6 +1,6 @@ use pretty_assertions::assert_eq; -use quick_xml::events::attributes::Attribute; use quick_xml::events::Event::*; +use quick_xml::events::attributes::Attribute; use quick_xml::events::{ BytesCData, BytesDecl, BytesEnd, BytesPI, BytesRef, BytesStart, BytesText, }; diff --git a/tests/roundtrip.rs b/tests/roundtrip.rs index 4ced4f10d..ba25685fb 100644 --- a/tests/roundtrip.rs +++ b/tests/roundtrip.rs @@ -1,11 +1,11 @@ //! Contains tests that checks that writing events from a reader produces the same documents. +use quick_xml::XmlVersion; use quick_xml::escape::unescape; use quick_xml::events::attributes::AttrError; use quick_xml::events::{BytesCData, BytesEnd, BytesStart, BytesText, Event::*}; use quick_xml::reader::Reader; use quick_xml::writer::Writer; -use quick_xml::XmlVersion; use pretty_assertions::assert_eq; diff --git a/tests/serde-de-xsi.rs b/tests/serde-de-xsi.rs index a2ff454cd..2350bfb32 100644 --- a/tests/serde-de-xsi.rs +++ b/tests/serde-de-xsi.rs @@ -1,8 +1,8 @@ //! Tests for ensure behavior of `xsi:nil` handling. //! //! We want to threat element with `xsi:nil="true"` as `None` in optional contexts. -use quick_xml::se::to_string; use quick_xml::DeError; +use quick_xml::se::to_string; use serde::{Deserialize, Serialize}; diff --git a/tests/serde-de.rs b/tests/serde-de.rs index a32bdf236..ffd443079 100644 --- a/tests/serde-de.rs +++ b/tests/serde-de.rs @@ -1,11 +1,11 @@ +use quick_xml::DeError; use quick_xml::de::Deserializer; use quick_xml::utils::{ByteBuf, Bytes}; -use quick_xml::DeError; use pretty_assertions::assert_eq; -use serde::de::IgnoredAny; use serde::Deserialize; +use serde::de::IgnoredAny; mod serde_helpers; use serde_helpers::from_str; @@ -1793,7 +1793,9 @@ mod borrow { #[test] fn attribute() { - match from_str::<BorrowedAttribute>(r#"<root string="with "escape" sequences"/>"#) { + match from_str::<BorrowedAttribute>( + r#"<root string="with "escape" sequences"/>"#, + ) { Err(DeError::Custom(reason)) => assert_eq!( reason, "invalid type: string \"with \\\"escape\\\" sequences\", expected a borrowed string" diff --git a/tests/serde-issues.rs b/tests/serde-issues.rs index 6320346f9..64046dbcb 100644 --- a/tests/serde-issues.rs +++ b/tests/serde-issues.rs @@ -4,7 +4,7 @@ use pretty_assertions::assert_eq; use quick_xml::de::{from_reader, from_str}; -use quick_xml::se::{to_string, to_string_with_root, Serializer}; +use quick_xml::se::{Serializer, to_string, to_string_with_root}; use serde::de::{Deserializer, IgnoredAny}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -990,8 +990,8 @@ mod issue953 { /// a stack overflow. Tests are ordered: struct (general, then `$value`), /// enum (newtype, tuple, struct variant), then siblings. mod issue978 { - use quick_xml::de::Deserializer as XmlDeserializer; use quick_xml::DeError; + use quick_xml::de::Deserializer as XmlDeserializer; use serde::Deserialize; /// Generate XML like `<S><field><field>...</field></field></S>`. diff --git a/tests/serde_helpers/mod.rs b/tests/serde_helpers/mod.rs index 4132239ae..daf3a320f 100644 --- a/tests/serde_helpers/mod.rs +++ b/tests/serde_helpers/mod.rs @@ -1,8 +1,8 @@ //! Utility functions for serde integration tests use pretty_assertions::assert_eq; -use quick_xml::de::Deserializer; use quick_xml::DeError; +use quick_xml::de::Deserializer; use serde::Deserialize; /// Deserialize an instance of type T from a string of XML text.