-
Notifications
You must be signed in to change notification settings - Fork 83
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 integer bitmask #157
Comments
To get the bytes as an integer, you can use |
As far as I can see that wouldn’t work with generic const exprs—the API should return |
In the case of generics, you could do something like: fn bitmask_to_u64<const BYTES: usize>(bitmask: [u8; BYTES]) -> u64 {
assert!(BYTES <= 8);
let mut padded = [0; 8];
padded[..BYTES].copy_from_slice(&bitmask[..BYTES]);
u64::from_ne_bytes(padded)
} |
I see. Thanks for the comment and the suggestion. I would want to abstract over the integer types in function of the associated type of the given supported lane, but I see it was misguided as there’s no std way to abstract over integers—i.e. if I want to I am using macros as it is, but if we could const abstract over integer primitives (e.g. Not sure how complex or desirable it’d be, and if this is the right place to kickstart a discussion, but it could be considered in light of this effort. |
Generic integers came up a few times when we were designing this interface--if they were available I think it would be the preferable route. I'm not sure how complex it would be either, but it's come up enough times that there's definitely some desire for it. We more or less settled on u8 arrays being "good enough", but not perfect. |
Resolved in #239. |
Maybe rename
to_bitmask
toto_bitmask_array
and restoreto_bitmask
to returnIntBitMask
as inpacked_simd
, or viceversa.The text was updated successfully, but these errors were encountered: