-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[derive] Derive TryFromBytes on unions (#800)
The implementation itself is very straightforward, but it requires a few prerequisite changes: - The `Ptr::project` method now requires that it only be called on struct and union types - The `AsInitialized` invariant property is changed in a subtle but important way. Previously, a byte offset in a type was required to be initialized if, in every instance of that type, it was initialized. Now, this is required if the byte is initialized in /any/ instance of the type. Without this change, it would be possible to invoke `TryFromBytes::is_bit_valid` on a byte sequence where an uninitialized byte appears which is valid for one union field but not valid for another. Since we check bit validity for all union fields, uninitialized bytes may only appear which are compatible with /all/ union fields.
- Loading branch information
Showing
4 changed files
with
226 additions
and
65 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
Oops, something went wrong.