3 ms·
When there was a lot of discussions about niche optimizations and integers that if we had const generics we could have `NonXXX` types which use const generics t
by dathinab 4y ago
When there was a lot of discussions about niche optimizations and integers that if we had const generics we could have `NonXXX` types which use const generics to specify the niche.
But back then we hadn't had const generics and it was time wise too far off to wait for const generics in anyform (including unstable rustc internal only usage of it).
So if now that we have const generics somone sits downs discusses the technical details on zulip, then writes a RFC and then writes an implementation we theoretically could have it soon.
Through I'm not sure how easy/hard the implementation part would be.
Some problems to discuss for standardization would be:
- is there any in progress work, overlapping RFC etc. (Idk. there should be older in progress work, but someone might be working on it right no idk). There could also be work on a more generic niche handling code which would happen to also cover this idk.
- should multiple niches be handled and if so how with which limitations (there are no variadic generic and ways to emulate them like through type nesting likely wouldn't have pef and complexity problems)
- can it be usefull for outside of optimizations to have e.g. a range limited integer
- if the gap is big enough (i.e. u32 limited to a hypothetical u24), should it interact with packed representation
- is there any risk of it being confusing/unexpected (should not be the case, but still needs to be evaluated)
EDIT: There seem to be unstable following attributes:
#[rustc_nonnull_optimization_guaranteed]
#[rustc_layout_scalar_valid_range_start(...)]
#[rustc_layout_scalar_valid_range_end(..)]