enum {type_name} {{ Int(i32), String(String), }} impl Default for {type_name} {{ fn default() -> Self {{ {type_name}::Int(0) }} }} impl {local}DeepMerge for {type_name} {{ fn merge_from(&mut self, other: Self) {{ *self = other; }} }} impl<'de> {local}serde::Deserialize<'de> for {type_name} {{ fn deserialize(deserializer: D) -> Result where D: {local}serde::Deserializer<'de> {{ struct Visitor; impl<'de> {local}serde::de::Visitor<'de> for Visitor {{ type Value = {type_name}; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {{ formatter.write_str({type_name:?}) }} fn visit_i32(self, v: i32) -> Result where E: {local}serde::de::Error {{ Ok({type_name}::Int(v)) }} fn visit_i64(self, v: i64) -> Result where E: {local}serde::de::Error {{ let v = v.try_into().map_err(|_| {local}serde::de::Error::invalid_value({local}serde::de::Unexpected::Signed(v), &"a 32-bit integer"))?; Ok({type_name}::Int(v)) }} fn visit_u64(self, v: u64) -> Result where E: {local}serde::de::Error {{ let v = v.try_into().map_err(|_| {local}serde::de::Error::invalid_value({local}serde::de::Unexpected::Unsigned(v), &"a 32-bit integer"))?; Ok({type_name}::Int(v)) }} fn visit_str(self, v: &str) -> Result where E: {local}serde::de::Error {{ self.visit_string(v.to_owned()) }} fn visit_string(self, v: String) -> Result where E: {local}serde::de::Error {{ Ok({type_name}::String(v)) }} }} deserializer.deserialize_any(Visitor) }} }} impl {local}serde::Serialize for {type_name} {{ fn serialize(&self, serializer: S) -> Result where S: {local}serde::Serializer {{ match self {{ {type_name}::Int(i) => i.serialize(serializer), {type_name}::String(s) => s.serialize(serializer), }} }} }}