quick-xml
quick-xml copied to clipboard
Lifetime on Attributes is wrong
So Attributes has a generic parameter 'a, but it doesn't correspond to the same lifetime of the slice inside the reader. It corresponds to the lifetime of the borrow of the reader itself when the Attributes object was created.
One can easily see that making this change will break the code:
diff --git a/src/events/mod.rs b/src/events/mod.rs
index 5e598bd..861ce7b 100644
--- a/src/events/mod.rs
+++ b/src/events/mod.rs
@@ -223,12 +223,12 @@ impl<'a> BytesStart<'a> {
}
/// Returns an iterator over the attributes of this tag.
- pub fn attributes(&self) -> Attributes {
+ pub fn attributes(&self) -> Attributes<'a> {
Attributes::new(&self.buf, self.name_len)
}
/// Returns an iterator over the HTML-like attributes of this tag (no mandatory quotes or `=`).
- pub fn html_attributes(&self) -> Attributes {
+ pub fn html_attributes(&self) -> Attributes<'a> {
Attributes::html(self, self.name_len)
}
I'm working on fixing that using as little as possible reallocations, which would mean having a double lifetime on Attributes.