compact_str
compact_str copied to clipboard
Safer Repr?
I had an idea to avoid transmuting Repr
s around by directly making use of the enum niche optimization. Basically, store ([u8; 23], LastUtf8Char)
in Inline
, restrict LastUtf8Char
to only actual valid last-bytes for the Inline
representation, then have Repr be an enum over Inline
/ Heap
/ &'static str
/ etc as desired, and the compiler will choose the discriminants for those variants.
See this Godbolt link.