-
Notifications
You must be signed in to change notification settings - Fork 114
Minimal implementation of TryFromBytes
#317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
joshlf
wants to merge
1
commit into
try-from-bytes-minimal-2-maybe-valid
from
try-from-bytes-minimal-3-try-from-bytes
Closed
Minimal implementation of TryFromBytes
#317
joshlf
wants to merge
1
commit into
try-from-bytes-minimal-2-maybe-valid
from
try-from-bytes-minimal-3-try-from-bytes
Conversation
This file contains hidden or 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
2019700
to
038ccb3
Compare
3802900
to
665ab99
Compare
038ccb3
to
d0ff76b
Compare
665ab99
to
ce8b5e8
Compare
d0ff76b
to
8ed6a15
Compare
ce8b5e8
to
0d31add
Compare
8ed6a15
to
b6457af
Compare
0d31add
to
52e942f
Compare
jswrenn
reviewed
Sep 5, 2023
d38f809
to
78aefe2
Compare
b6457af
to
98afbb5
Compare
78aefe2
to
56596ac
Compare
98afbb5
to
17a8cff
Compare
56596ac
to
041ef79
Compare
17a8cff
to
739d047
Compare
041ef79
to
fd5327f
Compare
739d047
to
9bc7911
Compare
fd5327f
to
9c4a7a4
Compare
9bc7911
to
4b14ee1
Compare
9c4a7a4
to
51ce251
Compare
4b14ee1
to
d32107e
Compare
51ce251
to
05003ee
Compare
d32107e
to
01345db
Compare
05003ee
to
7aff258
Compare
01345db
to
66c0c30
Compare
7aff258
to
c46c812
Compare
66c0c30
to
3115668
Compare
c46c812
to
f886e19
Compare
`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: Add tests Makes progress on #5
3115668
to
f5fc5ba
Compare
f886e19
to
6e16ad3
Compare
joshlf
commented
Nov 2, 2023
/// implementation of `TryFromBytes::is_bit_valid`. | ||
/// | ||
/// [1] https://doc.rust-lang.org/std/primitive.char.html#method.from_u32 | ||
unsafe_impl!(char: TryFromBytes; |bytes: &[u8; 4]| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust-lang/reference#1401 has landed; use u32
as a representation instead.
Superseded by #353 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a more minimal version of #279. Most notably, it doesn't rely on field projection, which was a significant source of complexity. A future PR which adds support for deriving
TryFromBytes
will need to tackle field projection.Makes progress on #5.