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
I recently found that I had made a typo and gave two different variants of an enum the same name using #[serde(rename=...)].
The code was something like,
#[derive(Deserialize,Serialize)]pubenumFoo{#[serde(rename = "bar")]Bar{qux:int,},// oops! meant to type "baz"#[serde(rename = "bar")]Baz{qux:int,},}
I was surprised that I didn't encounter any error when compiling, serializing, or deserializing.
A complicating factor is that (like in the example above) both variants have the same fields. Perhaps if this weren't the case, I would have encountered some errors while deserializing.
I can't think of any reason off-hand why it would be desirable to allow conflicting names. It seems like it would always cause loss of data.
Would it be possible to catch this type of conflict? Is there some reason I am not thinking of that allowing conflicting names is desired?
The text was updated successfully, but these errors were encountered:
I recently found that I had made a typo and gave two different variants of an enum the same name using
#[serde(rename=...)]
.The code was something like,
I was surprised that I didn't encounter any error when compiling, serializing, or deserializing.
A complicating factor is that (like in the example above) both variants have the same fields. Perhaps if this weren't the case, I would have encountered some errors while deserializing.
I can't think of any reason off-hand why it would be desirable to allow conflicting names. It seems like it would always cause loss of data.
Would it be possible to catch this type of conflict? Is there some reason I am not thinking of that allowing conflicting names is desired?
The text was updated successfully, but these errors were encountered: