Partially Tagged Enum Only Works with Some Deserializers
When using an enum that I refer to as "partially tagged", e.g:
#[derive(Deserialize)]
pub enum FooBar {
Foo(String),
#[serde(untagged)]
Bar(String),
}
Some deserializers accept it just fine and others don't seem to like it. serde_json for example is fine with it and can either accept a json representation of an externally tagged enum or just a string. But serde_yaml (I know it is deprecated but I need a yaml parser, so here we are) throws an error that says:
"untagged and internally tagged enums do not support enum input"
which I have traced back to the Visitor impl for serde's private ContentVisitor struct in the visit_enum implementation.
I'm guessing this means there is something that serde_json is doing to override(?) that visitor's impl the that serde_yaml isn't, or visa versa. I've been using serde for years but this is the first time I have had to dig into an advanced feature like this so some direction would be helpful.
I'm guessing I either have to
A: Manually implement Deserialize for FooBar
B: Contribute to serde_yml
If the latter is the case, it would be a huge help to point me to where serde_json is handling this edge case so I can check out some examples.
Thanks!