-
Notifications
You must be signed in to change notification settings - Fork 276
Closed
Labels
enhancementserdeIssues related to mapping from Rust types to XMLIssues related to mapping from Rust types to XML
Description
use std::borrow::Cow;
use serde::Deserialize;
#[derive(Deserialize)]
struct Root<'a> {
#[serde(borrow)]
rattr: Cow<'a, str>,
}
const XML: &str = r#"
<Root rattr="rattr">
</Root>
"#;
fn main() {
let r: Root = quick_xml::de::from_str(XML).unwrap();
assert!(matches!(r.rattr, Cow::Borrowed(_)));
}This assert fails.
I assume this is because of this call to visit_str (which should be visit_borrowed_str):
https://github.com/tafia/quick-xml/blob/master/src/de/escape.rs#L79
fn deserialize_str<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
V: Visitor<'de>,
{
let unescaped = self.unescaped()?;
#[cfg(not(feature = "encoding"))]
let value = self.decoder.decode(&unescaped)?;
#[cfg(feature = "encoding")]
let value = self.decoder.decode(&unescaped);
visitor.visit_str(&value) // <-- visit_borrowed_str here
}Unfortunately I was not able to make this work due to lifetimes not matching
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementserdeIssues related to mapping from Rust types to XMLIssues related to mapping from Rust types to XML