Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme.md example broken out of the box #195

Open
Tatsujinichi opened this issue Jan 18, 2023 · 0 comments
Open

readme.md example broken out of the box #195

Tatsujinichi opened this issue Jan 18, 2023 · 0 comments

Comments

@Tatsujinichi
Copy link

Tatsujinichi commented Jan 18, 2023

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#"BananaStore"#;
let should_be = Item {
name: "Banana".to_string(),
source: "Store".to_string(),
};

let item: Item = from_str(src).unwrap();
assert_eq!(item, should_be);

let reserialized_item = to_string(&item).unwrap();
assert_eq!(src, reserialized_item);
}
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running target\debug\example.exe
thread 'main' panicked at 'assertion failed: (left == right)
left: "<Item><name>Banana</name><source>Store</source></Item>",
right: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Item><name>Banana</name><source>Store</source></Item>"', src\main.rs:21:5
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
error: process didn't exit successfully: target\debug\example.exe (exit code: 101)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant