compact_str
compact_str copied to clipboard
`NonNull` vs `*const` in Repr
This is a question more than a bug report, but just asking in case it reveals something more useful...
-
Repr
's 1st field is a*const ()
. -
HeapBuffer
's 1st field is aptr::NonNull<u8>
. -
StaticStr
's 1st field is aptr::NonNull<u8>
.
HeapBuffer
and StaticStr
are both transmuted to Repr
.
Is there a benefit to HeapBuffer
and StaticStr
using NonNull<u8>
rather than *const
? Does it matter that a value with a niche is transmuted to one without?
Second smaller question: Why *const ()
in Repr
instead of *const u8
? Only place which accesses this field seems to be as_slice
, where it's immediately cast to *const u8
. Probably it makes no difference to codegen, but I'm wondering if there's a subtlety I'm missing.