Announcing `compact_str` version 0.4! A small string optimization for Rust
Hey folks, I'm announcing version 0.4 of compact_str a small string optimization for Rust. This library exports a struct CompactString which can inline strings up to 24 characters long (12 on 32-bit machines), and a trait ToCompactString which exposes a method for turning types into a CompactString.
With this release comes several improvements:
- Rename
CompactStrtoCompactStringto better reflect that we own the underlying string buffer - Introduce the
ToCompactStringtrait with specializations for some basic types - Implement various
Add<T>forCompactString, allowing concatenation with+ - Several performance improvements around the creation of a
CompactString - Implements
std::fmt::WriteforCompactString O(1)conversion fromStringandBox<str>- Implements
Extend<Cow<'_, str>>andFrom<Cow<'_, str>>forCompactString
GitHub: https://github.com/ParkMyCar/compact\_str
crates.io: https://crates.io/crates/compact\_str
Special thanks to u/kijewski_, @mcronce, u/NobodyXu, and u/CAD1997 for their contributions!