...
requirements = {
country = ENG
prestige = 10
}
...
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct Event {
requirements: Vec<Condition>,
}
#[derive(Clone, Debug, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum Condition {
Country { country: String },
Prestige { prestige: u32 }
}
But I can't get it to work, with or without named fields in the enums, with or without untagged
. I'd like to be able to write something like this
#[derive(Clone, Debug, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum Condition {
#[serde(rename="country)]
Country(String),
#[serde(rename="prestige")]
Prestige(u32)
}
And have it interpret the 1-field enum alternatives correctly. I wasn't able to use JominiDeserialize with enums either. Is something like this supported?