RReverser / serde-xml-rs

xml-rs based deserializer for Serde (compatible with 1.0+)
https://crates.io/crates/serde-xml-rs
MIT License
269 stars 90 forks source link

Error `DocumentStartAlreadyEmitted` while trying to serialize simple structure in 0.6.0 #197

Open codebling opened 1 year ago

codebling commented 1 year ago

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