Interaction between serde and strum that results in a compiler error #73
Comments
Hi! Thanks for reporting this issue, and sorry for the delay. The problem is that the newly created Discriminants enum doesn't implement The current solution is to add a In this particular case, it would look something like: #[derive(Serialize, Deserialize, Debug, EnumDiscriminants)]
#[serde(tag = "type")]
#[strum_discriminants(derive(Serialize, Deserialize))]
enum Message {
#[serde(rename = "request" )]
Request { id: String, method: String, params: u8 },
#[serde(rename = "response" )]
Response { id: String, result: u8 },
} |
Heya, I've opened #82 which is one way to resolve this. Hopefully the whitelist is sensible -- I've been using it for a number of projects and haven't run into any weird problems. |
Hi!
I've noticed that using strum's derive
EnumDiscriminants
with some serde variant attributes, results in a compiler error.I'm not sure of this is an issue in strum, in serde, or both.
Here's a program to reproduce the issue:
Cargo.toml
src/main.rs
Compiler error
Additional info
The program compiles successfully if the lines
#[serde(rename = "response" )]
are removed.The text was updated successfully, but these errors were encountered: