This repository has been archived by the owner on Aug 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix encoding of packed variants in new enum format
Fixes #187 Legacy enum format supported packed encoding pretty well but with the switch to new enum format there was a regression (#173). This commit fixes the new enum format in packed encoding. For example consider the following structure: ```rust enum Enum { Unit, NewType(i32), Tuple(i32, i32), Struct { x: i32, y: i32 }, } ``` Legacy enum packed encodings are: ``` Empty: <variant number> NewType: [<variant number>, value] Tuple: [<variant number>, values..] Struct: [<variant number>, {<struct>}] ``` Non-legacy enum packed encodings before this commit: ``` Empty: <variant number> NewType: {"<variant>": value} Tuple: {"<variant>": [values..]} Struct: {<variant number>: {<struct>}} ``` Notice how NewType and Tuple store the name instead of variant number. Fixed after this commit: ``` Empty: <variant number> NewType: {<variant number>: value} Tuple: {<variant number>: [values..]} Struct: {<variant number>: {<struct>}} ``` After this commit the packed encoding can be briefly described as: All struct fields and enum variants are encoded as their field number rather than name. This applies to all types of members (unit, newtype, tuple and struct).
- Loading branch information
Showing
3 changed files
with
56 additions
and
32 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