detrim

Crates.iodetrim
lib.rsdetrim
version0.1.4
sourcesrc
created_at2024-05-19 12:45:01.387429
updated_at2024-10-10 12:41:32.142513
descriptionAutomatic string trimming with serde
homepage
repositoryhttps://github.com/x52dev/detrim
max_upload_size
id1244898
size35,542
Rob Ede (robjtede)

documentation

README

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");
Commit count: 74

cargo fmt