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

Serialization and deserialization errors #177

Open bahetiai opened 2 years ago

bahetiai commented 2 years ago

Code:

use serde;
use serde::{Deserialize, Serialize};
use serde_xml_rs::{from_str, to_string};

#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct Item {
    name: String,
    source: String,
}

fn main() {
    let src = r#"<Item name="Banana"><source>Store</source></Item>"#;
    let item:Item = from_str(&src).unwrap();
    let item = to_string(&item).unwrap();
    assert_eq!(src,item);
}

but i got error

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"<Item name=\"Banana\"><source>Store</source></Item>"`,
 right: `"<Item><name>Banana</name><source>Store</source></Item>"`', src/main.rs:15:5