#deserialize #serde #utilities

no-std detrim

Automatic string trimming with serde

3 releases

0.1.4 Oct 10, 2024
0.1.3 May 26, 2024
0.0.0 May 19, 2024

#433 in Encoding

Download history 150/week @ 2024-07-30 489/week @ 2024-08-06 1125/week @ 2024-08-13 1209/week @ 2024-08-20 1159/week @ 2024-08-27 1193/week @ 2024-09-03 1008/week @ 2024-09-10 1086/week @ 2024-09-17 1928/week @ 2024-09-24 1561/week @ 2024-10-01 1544/week @ 2024-10-08 1705/week @ 2024-10-15 1526/week @ 2024-10-22 1553/week @ 2024-10-29 1325/week @ 2024-11-05 857/week @ 2024-11-12

5,745 downloads per month

MIT/Apache

23KB
530 lines

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");

Dependencies

~100–330KB