forked from serde-rs/serde
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix roundtrip of enum with skipped variant
On enums with a skipped variant that is not the last one, the generated serialization and deserialization code map the variants of the enum to different variant indices. In `deserialize_identifier`, the variant index starts at 0 and counts up once per non-skipped variant. However, for serialization the index is always the index of the variant within the enum. This PR corrects the deserialization code to always use the index of the variant within the enum. This was surfaced in jamesmunns/postcard#79.
- Loading branch information
Showing
3 changed files
with
29 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters