The following extremely simple code reproduces the issue.
enum EnumOne {
A(EnumTwo),
}
enum EnumTwo {
Z(StructOne),
}
struct StructOne {
}
let obj = EnumOne::A(
EnumTwo::Z (
StructOne {
}
)
);
serde_xml_rs::to_string(&obj).unwrap();
And produces the following error
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Writer { source: DocumentStartAlreadyEmitted }', src/main.rs:24:33
I've created a minimal repo which reproduces the issue
Versions are
serde = "1.0.152"
serde-xml-rs = "0.6.0"
The code works in serde-xml-rs 0.5.1