Is it possible to enable more niche optimizations for reference types by utilizing unaligned values? #134675
Labels
C-discussion
Category: Discussion or questions that doesn't represent real issues.
To my understanding, currently, a reference type has only one niche that is the null value, but a reference type must be properly aligned, which means in theory we can also utilize those unaligned values as niches. The total possible niches of a type can be calculated as:
where
MEMORY_SPACE_SIZE
is the theoretical maximum size of the memory space in bytes.Is it possible for Rust to enable this optimization?
Additionally, is it possible to add a new
NonNullAligned<T>
type that has the same niches as&T
? We can use it to implementBox
,Rc
,Arc
andVec
types, so they can also have the same niches.The text was updated successfully, but these errors were encountered: