An Optimization That's Impossible in Rust
tunglevo.com
tunglevo.com
1. Both `Vec<u8>` and `String` should share the same layout as part of the standard library's contract.
2. Unlike `String`, the equivalent optimization for `Vec<T>` is more questionable especially when T might be any type. C++ standard libraries frequently do implement multiple layouts for std::string but not for std::vector<T> for the same reason.
3. Rust never allows an implicit copying of `String` in the first place, which greatly benefits from the SSO, so the lack of SSO in Rust is less important compared to C++.
[1] https://github.com/rust-lang/rust/issues/4991
[2] https://github.com/rust-lang/rust/issues/20198
[3] https://github.com/rust-lang/rfcs/pull/2990
[4] https://github.com/rust-lang/unsafe-code-guidelines/issues/4...