The following code fails at the unwrap() (with the error 'Syntax(invalid type: string "Variant", expected enum Enum, 0, 0)').
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
enum Enum {
Variant,
}
#[test]
fn round_trip() {
let variant = Enum::Variant;
let string = serde_hjson::to_string(&variant).unwrap();
assert_eq!(&string, "Variant");
let round_trip: Enum = serde_hjson::from_str(&string).unwrap(); // fails here
assert_eq!(variant, round_trip);
}
A workaround I have found is to have the enum be internally tagged, (i.e. add #[serde(tag="tag")] or equivalent), which does allow the round-trip to work, but changes the serialized format so may not work for all use cases.
This is on serde-hjson = 1.1.0 with serde = 1.0.228.
The following code fails at the
unwrap()(with the error 'Syntax(invalid type: string "Variant", expected enum Enum, 0, 0)').A workaround I have found is to have the enum be internally tagged, (i.e. add
#[serde(tag="tag")]or equivalent), which does allow the round-trip to work, but changes the serialized format so may not work for all use cases.This is on
serde-hjson = 1.1.0withserde = 1.0.228.