-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add byte conversions #72
base: main
Are you sure you want to change the base?
Conversation
this seems to work from the very basic tests I did I asked around and if the bounds check of in the
if we go by the API guidelines it should take why does this not work for non-repr enums? this could be a good place to use |
👍
right, it was about Copy
rust doesn't know that the enum is
it returns [3, 0, 0, 0] on lil, [0, 0, 0, 3] on big endian right now, which is correct, right? |
#[cfg(target_endian = "little")] | ||
{ | ||
// [1 1 1 1 1] 0 0 0 | ||
return full[..MIN_BYTES].try_into().unwrap(); |
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.
is this just transmute_copy(self)? because it's already in little endian?
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.
that's true, that's also how the impl started.
though it's a bit more explicit like this, but I might change it back when doing the other methods
ah, I see.
I would expect [42, 0, 0, 0] / [0, 0, 0, 42] here |
that's |
oops, yeah. I meant |
@pickx any non c-like enum or struct containing a non c-like enum can't be transmuted since it contains discriminant and value... |
Closes #33.
this is for testing big endian:
&self
orself
?can this rotate_left-then-slice-try_into setup be easier?
also this will probably not stay in bitsize_internal, I still don't believe everyone needs this...
also useful as a trait, I mean it's basically adapted from here / here.