-
Notifications
You must be signed in to change notification settings - Fork 12
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
le and be #9
Comments
I've tried implementing it but need to test it with bitfields first. /// u24
pub const fn from_ne_bytes(bytes: [u8; 3]) -> Self { //mem::size_of::<Self>() can't be used, would be 4
unsafe { mem::transmute(bytes) } //can't be used, we're 4 bytes wide, so we need to add a 0 byte
}
|
Would such functions even be well-defined for everything? What does it mean for a u19 to be be vs le? I can see how it makes sense in bitfield, but in arbitrary_int, should we limit this to multiples of 8? |
I noticed that as well while implementing and proceeded to do multiples of 8. |
This is still lying around somewhere, will try to add this soon. |
"soon" |
Working on this. Have swap_bytes and to_le_bytes (and ne and be) ready. from_ne_bytes is slightly more tricky, macro wise. Will upload a patch shortly |
https://doc.rust-lang.org/src/core/num/uint_macros.rs.html
to_le/to_be
from_le/from_be
After reading issues like this: Robbepop/modular-bitfield#46
I wondered how this could be handled by us.
Adding these 4 functions would mirror the primitive numbers and they afaik just need to call their UnderlyingType's functions.
The text was updated successfully, but these errors were encountered: