Why can [serde::rename]
specify deserialize
? In my case, I need the following to replace hyphens by underscores:
#[derive(Serialize, Deserialize, Debug)]
pub struct ProjectSettings {
#[serde(rename = "short-id")]
pub short_id: String,
#[serde(rename = "full-id")]
pub full_id: String,
}
I've not tested it yet (this will be my first time manipulating Toml), but I'm finding serde
's documentation a bit vague on this. Isn't only serialize
name needed for [serde(rename)]
? Field attributes · Serde What does deserialize
do for [serde(rename)]
?