You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// `Other` is a single-variant enum since using a newtype struct results in the name being lost entirely, which I believe is a serde issue.#[derive(Debug,Serialize,Deserialize)]enumOther{Env(String),}#[derive(Debug,Serialize,Deserialize)]#[serde(untagged)]enumMaybeEnv{Value(String),Other(Other),}
This is set up like this to allow using a raw String literal or a fallback which executes different behavior (in this case reading the string from the environment), but only if it's wrapped in Env.
However, when deserializing Env("bar") it fails with "data did not match any variant of untagged enum MaybeEnv" instead of MaybeEnv::Other(Other::Env("bar")). I'm also unable to find a string which properly deserializes to this value at all.
I'm unsure if this is a serde limitation, but it's relatively surprising behavior since it serializes properly but fails to deserialize.
The text was updated successfully, but these errors were encountered:
juntyr
added a commit
to juntyr/ron
that referenced
this issue
Aug 31, 2023
Consider the following implementation
This is set up like this to allow using a raw String literal or a fallback which executes different behavior (in this case reading the string from the environment), but only if it's wrapped in
Env
.The following works properly:
MaybeEnv::Value("foo")
outputs"foo"
MaybeEnv::Other(Other::Env("bar"))
outputsEnv("bar")
"foo"
results inMaybeEnv::Value("foo")
However, when deserializing
Env("bar")
it fails with"data did not match any variant of untagged enum MaybeEnv"
instead ofMaybeEnv::Other(Other::Env("bar"))
. I'm also unable to find a string which properly deserializes to this value at all.I'm unsure if this is a serde limitation, but it's relatively surprising behavior since it serializes properly but fails to deserialize.
The text was updated successfully, but these errors were encountered: