Skip to content

Commit

Permalink
add trimming option for the de::from_* functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Pigeon committed Feb 23, 2023
1 parent f0b3420 commit 86cbc33
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 114 deletions.
6 changes: 3 additions & 3 deletions examples/read_nodes_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// run example with:
// cargo run --example read_nodes_serde --features="serialize"

use quick_xml::de::from_str;
use quick_xml::de::{from_str, Trimmer};
use serde::Deserialize;

#[derive(Debug, PartialEq, Default, Deserialize)]
Expand Down Expand Up @@ -66,12 +66,12 @@ const ONE_TRANSLATION_XML: &str = r#"
"#;

fn main() -> Result<(), quick_xml::DeError> {
let t: Translation = from_str(ONE_TRANSLATION_XML)?;
let t: Translation = from_str(ONE_TRANSLATION_XML, Trimmer::default())?;
assert_eq!(t.tag, "HELLO");
assert_eq!(t.lang, "ja");
assert_eq!(t.text, "こんにちは");

let config: Config = from_str(XML)?;
let config: Config = from_str(XML, Trimmer::default())?;
dbg!("{:?}", &config);

assert_eq!(config.settings.language, "es");
Expand Down
Loading

0 comments on commit 86cbc33

Please sign in to comment.