Skip to content
/ detrim Public

Deserialization trimming for strings in serde models.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

x52dev/detrim

Repository files navigation

detrim

crates.io Documentation dependency status MIT or Apache 2.0 licensed
CI codecov Version Download

Deserialization trimming for strings in serde models.

Examples

#[derive(Debug, serde::Deserialize)]
struct Form {
    #[serde(deserialize_with = "detrim::string")]
    name: String,
}

let form = serde_json::from_str::<Form>(r#"{ "name": "ferris" }"#).unwrap();
assert_eq!(form.name, "ferris");

let form = serde_json::from_str::<Form>(r#"{ "name": "  ferris   " }"#).unwrap();
assert_eq!(form.name, "ferris");