-
Notifications
You must be signed in to change notification settings - Fork 8
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
Possibility to be zero-cost on some platforms #20
Comments
I'm not sure what you mean by 'and larger' as to my knowledge you can't construct larger types out of the smaller niched types because you will end up with too many niches? However there are still a few platform specific types available, all in
|
You're correct, I think the reason I didn't initially consider these was because their width changes depending on the platform's usize, so in practice you'll miss out on
#[repr(C, align(8))]
pub struct NonMaxU64 {
hi: NonMaxU32,
lo: u32,
}
|
Unfortunately combining types like this doesn't work because it will then have As an aside we can make |
You're right, that's my mistake |
It would be possible (maybe slightly cursed?) to implement
NonMaxU32
(and larger) in terms of some stable standard library type that already has a niche atu32::MAX
, removing the run-time costs.There unfortunately are not a lot of these, but I found
std::os::fd::BorrowedFd
which is available instd
on Unix platforms & WASI and has been stable since 1.63.0.Proof of concept
The text was updated successfully, but these errors were encountered: