Commit 94130a9
committed
Add TryFromBytes trait
`TryFromBytes` can be implemented for types which are not `FromZeroes`
or `FromBytes`; it supports performing a runtime check to determine
whether a given byte sequence contains a valid instance of `Self`.
This is the first step of #5. Future commits will add support for a
custom derive and for implementing `TryFromBytes` on unsized types.
TODO:
- More thorough tests for non-FromBytes types (bool, char, etc)
- Tests that go through the `TryFromBytes` public methods rather than
testing `is_bit_valid` directly
- Pick public TryFromBytes method names that are more consistent with
FromBytes? In particular:
- try_from_ref -> try_from_bytes
- try_from_mut -> try_from_bytes_mut
Makes progress on #51 parent ae4e308 commit 94130a9
3 files changed
Lines changed: 1005 additions & 173 deletions
0 commit comments