Hacker News new | past | comments | ask | show | jobs | submit
That removes the allocation but keeps the overhead of a pointer, a capacity and a fixed buffer.

And these strings in Goose are 6 bytes, while the ones in C++ are apparently 16 to 24 bytes each.

But equally they could be a Rust cold_string::ColdString which is either 8 bytes or 4 bytes depending on your target. The 4 byte ColdString is just the bytes 0x77 0x6f 0x72 0x64 to spell "word" in ASCII / UTF-8 [for 8 bytes the current ColdString just stores 0xFF in the other four bytes to denote they are not used]

Rust has had more interesting SSO types than C++ perhaps explicitly because it doesn't come with SSO out of the box although maybe also because C++ still isn't sure whether text is UTF-8 encoded even though it is 2026 now.