Why would you store the size and capacity as part of the buffer? It makes the buffer more complex (you need a separate unsized struct or some mess special-casing the first 16 bytes or so), wastes heap size, requires dereferencing before you can even check on size & capacity, and makes SSO harder/more limited.
AFAIK both C++'s std::string and Rust's String store size and capacity on the stack, separate from the buffer.
To decrease the memory footprint of your small strings. It can see how some uses cases where a large proportion of strings are very small would benefit from it.
I was just curious to know if that design decision was based on analysis of a real use case, or if it was due to a compatibility issue or something.
If you're coming from a GC'd language like Java, Ruby, etc, then there's a bit of a mindset shift around strings.
If you do that you have to spill your SSO to the heap way earlier, rapidstring would have 15 bytes SSO instead of the current 31, and std::string would be limited to 7 compared to the current 23~31.