3 ms·
I wasn't familiar with Serde's description of this so that was a good read, thanks. Although I still think this is a bad example of an externally tagged repres
by mindwok 3y ago
I wasn't familiar with Serde's description of this so that was a good read, thanks.
Although I still think this is a bad example of an externally tagged representation. In the Serde example they have the key as "Request" then what follows is the request object. In this example, the "success" key is followed by an arbitrary string message, which isn't obvious at all.
- Nullabillity 3y agoThe contents of each variant don't really matter here. The tag represents the variant, not the type contained inside of it. The Serde equivalent here would be: #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum Response { Success(serde_json::Value), Error(serde_json::Value), }