Fix bug where nested structs with the same element names didn't deserialzie properly.
This commit is contained in:
parent
fb19a35d43
commit
72d61e03f4
@ -1052,6 +1052,5 @@ fn de_same_field_name_but_some_other_fields_or_something() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
serialize_and_validate!(model, content);
|
serialize_and_validate!(model, content);
|
||||||
// TODO fix it
|
deserialize_and_validate!(content, model, FooOuter);
|
||||||
// deserialize_and_validate!(content, model, FooOuter);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -367,16 +367,23 @@ pub fn parse(
|
|||||||
);
|
);
|
||||||
match event {
|
match event {
|
||||||
::xml::reader::XmlEvent::StartElement{ref name, ref attributes, ..} => {
|
::xml::reader::XmlEvent::StartElement{ref name, ref attributes, ..} => {
|
||||||
match name.local_name.as_str() {
|
if depth == 0 && name.local_name == #root {
|
||||||
#call_visitors
|
// Consume root element. We must do this first. In the case it shares a name with a child element, we don't
|
||||||
_ => {
|
// want to prematurely match the child element below.
|
||||||
let event = reader.next_event()?;
|
let event = reader.next_event()?;
|
||||||
#write_unused
|
#write_unused
|
||||||
|
} else {
|
||||||
|
match name.local_name.as_str() {
|
||||||
|
#call_visitors
|
||||||
|
_ => {
|
||||||
|
let event = reader.next_event()?;
|
||||||
|
#write_unused
|
||||||
|
|
||||||
if depth > 0 { // Don't skip root element
|
if depth > 0 { // Don't skip root element
|
||||||
reader.skip_element(|event| {
|
reader.skip_element(|event| {
|
||||||
#write_unused
|
#write_unused
|
||||||
})?;
|
})?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user