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
Only assert_ser_tokens pays attention to this len, comparing it against the len passed to serialize_struct, while assert_de_tokens just ignores it, as you found.
One might expect assert_de_tokens to compare this len against the number of field names passed by the Deserialize impl to deserialize_struct.
The reason that is not a good option is because sometimes these 2 disagree.
For example, this struct always has 3 possible field names for deserialization, but always serializes 2 fields.
As one counterproposal perhaps assert_de_tokens should pay attention and assert_tokens should not. Currently assert_tokens is equivalent to assert_ser_tokens + assert_de_tokens and I think we are better off keeping it that way.
Another possibility is make assert_de_tokens compare the len not against the field names of the deserialize_struct call, but against the number of fields actually present in the test tokens list. I think that's not so useful; the point is to test the Deserialize impl, not test the test code. This only makes the test code more tedious.
I just noticed this anomaly in the code I provided for a different issue.
The struct only has two fields, but the test is checking for
len: 5
, and still passes.The text was updated successfully, but these errors were encountered: