#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

#485 in Encoding

Download history 1097/week @ 2024-08-15 1298/week @ 2024-08-22 966/week @ 2024-08-29 1239/week @ 2024-09-05 1029/week @ 2024-09-12 1345/week @ 2024-09-19 1781/week @ 2024-09-26 1564/week @ 2024-10-03 1521/week @ 2024-10-10 1771/week @ 2024-10-17 1740/week @ 2024-10-24 1375/week @ 2024-10-31 867/week @ 2024-11-07 1687/week @ 2024-11-14 1569/week @ 2024-11-21 1284/week @ 2024-11-28

5,655 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

~105–330KB