Small-Size-Optimized (SSO) Strings (Arrays)


#1

Does rust have small size optimized strings (and arrays)?

And are these iterator compatible?


#2

In the standard library the implementation looks straightforward, so I’m guessing it doesn’t have that optimization:

There’s a crate for small strings: https://crates.io/crates/inlinable_string

Also note that slices (including &str) use fat pointers to store length, so for them there’s no extra storage overhead.

Types can be made compatible with iterators by implementing traits such as Iterator/IntoIterator, so standard library strings are not special in that regard.


#3

See this thread: