Has there been any discussion of having String live entirely on the stack for len < size_of::<usize>() * n? Imagine
enum StringInner {
Stack {
len: u8,
bytes: [u8; N],
},
Heap(Vec<u8>),
}
Of course, off the top of my head I don’t know how well this plays with existing APIs, but I wanted to put down the idea for discussion before I mull it over more.
Note that this is the same size of the current String, if we use StringInner::Heap.0's RawVec's Unique as a niche. I have no idea if @eddyb’s work on niches can handle something like this, though.