RReverser / serde-xml-rs

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

error order when serde a enum field #207

Open cathaysia opened 1 year ago

cathaysia commented 1 year ago

I had this pragram:

use serde::Serialize;

#[derive(Serialize)]
enum Anmial {
    Cat,
    Dog,
}

#[derive(Serialize)]
struct A {
    field: Anmial,
}

fn main() {
    let v = A { field: Anmial::Cat };
    println!("{}", serde_xml_rs::to_string(&v).unwrap());
}

then the result is :

<?xml version="1.0" encoding="UTF-8"?>
<A>
    <Cat>
        <field />
    </Cat>
</A>

what I expect is :

<?xml version="1.0" encoding="UTF-8"?>
<A>
    <Field>
        <Cat />
    </Field>
</A>