Closed rossmacarthur closed 4 years ago
I also considered supporting serde
, but I didn't implement it because the amount of code is almost the same even if I use serde_with
as below.
use serde_with::{DeserializeFromStr, SerializeDisplay};
#[derive(Display, FromStr, PartialEq, Debug, SerializeDisplay, DeserializeFromStr)]
#[display(style = "snake_case")]
pub enum MyType {
A,
B,
}
Ah, I think I must have missed those derives in the serde_with
docs.
This might be out of scope for this crate, but it would be a cool feature to be able to automatically implement
serde
serialization and deserialization using theDisplay
andFromStr
implementations.Some thing like this maybe?
And this would implement the following type of
serde
Deserialize
implementationI am aware things like serde_with can do something similar, but then I have to annotate all the places I'm using it.