-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Case
XML source file can contain element <Element/> or <Element>text</Element> or not contain the span.
The type for it should be defined as:
#[derive(Debug, PartialEq, XmlRead, XmlWrite)]
#[xml(tag = "Parent")]
pub struct Parent<'a> {
#[xml(child = "Element")]
pub element: Option<Element<'a>>,
}
#[derive(Debug, PartialEq, XmlRead, XmlWrite)]
#[xml(tag = "Element")]
pub struct Element<'a> {
#[xml(text)]
pub content: Option<Cow<'a, str>>,
}Expected behavior
<Element>text<Element/>=>textis loaded into the instance<Element/>=>parent->element->contentshould beNone- not specified =>
parent->elementshould beNone
Or in case of defining the Element with flatten_text the case 2 and 3 can either have the same outcome or parent-element->text should be an empty/default value (empty string) for case 2.
Actual behavior
Case 1 and 3 work as expected. With case 2, however, I'm getting the following error:
UnexpectedToken { token: "ElementEnd { end: Empty, span: StrSpan(\"/>\" 2005..2007) }" }'
Same thing when using flatten_text.
Related issue
Having
#[derive(Debug, PartialEq, XmlRead, XmlWrite)]
#[xml(tag = "Element")]
pub struct Element<'a> {
#[xml(text)]
pub content: Option<Cow<'a, str>>,
}Has error
| #[derive(Debug, PartialEq, XmlRead, XmlWrite)]
| ^^^^^^^^ expected `str`, found reference
|
= note: expected reference `&str`
found reference `&&std::option::Option<std::borrow::Cow<'_, str>>`Although it says that Option<Cow<str>> should be supported. I can implement the XmlWrite myself, but that results in the issue mentioned above.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels