rustc_layout_scalar_valid_range_start, rustc_layout_scalar_valid_range_end, rustc_nonnull_optimization_guaranteed have proved themselves quite useful and a clever use of rust's safety guarantees.
I think these(probably under different names?) can be of great service to users/libraries outside of libcore too.
And because they require unsafe to write into the object I think they won't be too easily misused.
for example, I can Imagine NonNegative
i32 being used quite often, and will have more than 1 bit for niche.
Would love to hear what do people think and if the strong wording against this being ever stabilized are just because it's a rustc attribute or for some other/deeper reason.
I feel that this functionality is better exposed with const generics than attributes. It would essentially be an expanded version of
Hmm sounds interesting, how would that look like?
I found myself wanting this as well, recently. I have some large data structures that could be optimized by creating specialized types that have large niches.
How far is const generics from being ready for stable? How far is this set of attributes from being something that could be ready for stable? Probably, attributes would be a lot more practical a lot sooner.
RangeU32<min: u32, max: u32>