-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Description
I've encountered an issue with the yaserde_derive feature where a grandchild of the namespaced root node is not being deserialised. The child and grandchild nodes are both deserialised correctly when they are processed separately, without the root node as their ancestor.
Test case:
use yaserde::YaDeserialize;
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(rename = "EBMLSchema", namespace = "some_namespace")]
struct Schema {
#[yaserde(rename = "element")]
elements: Vec<Element>,
}
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(rename = "element")]
struct Element {
#[yaserde(rename = "documentation")]
documentation: Vec<Documentation>,
}
#[derive(YaDeserialize, Debug, PartialEq)]
#[yaserde(rename = "documentation")]
struct Documentation {
#[yaserde(text)]
body: String,
}
#[test]
fn nested_element_equality() {
let parent = r#"<EBMLSchema xmlns="some_namespace">
<element>
<documentation>Test</documentation>
</element>
</EBMLSchema>"#;
let parent: Schema = yaserde::de::from_str(parent).unwrap();
let child = r#"<element>
<documentation>Test</documentation>
</element>"#;
let child: Element = yaserde::de::from_str(child).unwrap();
assert_eq!(parent.elements[0], child);
}
Output:
thread 'nested::nested_element_equality' panicked at examples\src\nested.rs:38:3:
assertion `left == right` failed
left: Element { documentation: [] }
right: Element { documentation: [Documentation { body: "Test" }] }
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/std\src\panicking.rs:662
1: core::panicking::panic_fmt
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:74
2: core::panicking::assert_failed_inner
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\panicking.rs:412
3: core::panicking::assert_failed<yaserde_examples::nested::Element,yaserde_examples::nested::Element>
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\panicking.rs:367
4: yaserde_examples::nested::nested_element_equality
at .\src\nested.rs:38
5: yaserde_examples::nested::nested_element_equality::closure$0
at .\src\nested.rs:25
6: core::ops::function::FnOnce::call_once<yaserde_examples::nested::nested_element_equality::closure_env$0,tuple$<> >
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library\core\src\ops\function.rs:250
7: core::ops::function::FnOnce::call_once
at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14\library/core\src\ops\function.rs:250
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels