This repository was archived by the owner on Dec 17, 2024. It is now read-only.
Description I found, that there are two ways to express how the enum should be serialized:
#[ derive( Deserialize , Serialize , Debug , PartialEq ) ]
enum Enum {
Unit ,
}
assert_tokens (
& Enum :: Unit ,
& [
Token :: Enum { name : "Enum" } ,
Token :: Str ( "Unit" ) ,
Token :: Unit ,
] ,
) ;
assert_tokens (
& Enum :: Unit ,
& [
Token :: UnitVariant { name : "Enum" , variant : "Unit" } ,
] ,
) ;
Surprisely, both of that asserts are passed, although is is obvious that serialization can give only one of that results. After examining code I've found this very confusing check:
https://github.com/serde-rs/serde/blob/0c6a2bbf794abe966a4763f5b7ff23acb535eb7f/serde_test/src/ser.rs#L184-L190
That means that tester will change it's behavior depending on the testing data, that is not expected from the testing tool.
So the questions are:
why both variants are exist?
what one should use?
isn't it necessary to keep only one of them?
Reactions are currently unavailable
I found, that there are two ways to express how the enum should be serialized:
Surprisely, both of that asserts are passed, although is is obvious that serialization can give only one of that results. After examining code I've found this very confusing check:
https://github.com/serde-rs/serde/blob/0c6a2bbf794abe966a4763f5b7ff23acb535eb7f/serde_test/src/ser.rs#L184-L190
That means that tester will change it's behavior depending on the testing data, that is not expected from the testing tool.
So the questions are: