Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Parser position tracking
Store an
Option<quick_xml::reader::Span>
inside each of thequick_xml::events::Bytes*
structs. This span is computed by the parser during reading, and passed into the relevantwrap()
function during value construction. It can be accessed by calling relevantspan()
methods, which will clone and return the span (Range
, sadly, does not implementCopy
due to its status as anIterator
implementation.)Additionally, the derive implementations ofParagraph rendered obsolete by design change.PartialEq
on the structs is replaced with a manual implementation ofPartialEq
. This is to prevent previouslytrue
equality comparisons such asbytes == BytesStart::new("...", 4)
suddenly changing their behaviour to returnfalse
. This does mean that we lose our implementations ofStructuralPartialEq
, meaning that constants of the relevant types can no longer be used as patterns in match arms. However, sincequick_xml
exposes no way to construct values of these types at compile time, and sinceStructuralPartialEq
is currently nightly-only and therefore cannot be used in trait bounds in stable Rust, I do not believe this change is sufficiently observable to require a major version bump under semver.Other than the above, I do not intend to make any other possibly breaking changes to the public API with this contribution.
Changes
Bytes*
structs underquick_xml::events
receives a new field,span: crate::reader::Span
.n..m
, representing the start and end positions of that event's contents - for tags, this is the positions of the<
and>
character; while for text, it is the start and end of the text content, with respect to optional whitespace trimming.0..0
.Spanned
, which defines methods to retrieve and update the stored span.Progress
quick_xml::events::BytesStart
quick_xml::events::BytesDecl
BytesStart
quick_xml::events::BytesEnd
quick_xml::events::BytesText
quick_xml::events::BytesCData
quick_xml::events::Event
to return the underlying span if there is onequick_xml::events::attributes::Attributes
quick_xml::events::attributes::Attribute
quick_xml::events::attributes::Attr
quick_xml::errors::Error
quick_xml::escape::EscapeError
quick_xml::events::attributes::AttrError
quick_xml::name::QName
quick_xml::name::LocalName
quick_xml::name::Prefix
quick_xml::name::Namespace
PR changelog