Announcing `compact_str` version 0.5! A small string optimization for Rust
Hey folks, I'm announcing version 0.5 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 two traits, ToCompactString and CompactStringExt, which expose methods for turning different types into a CompactString. As well as a single macro, format_compact!, which allows you to create a CompactString from various arguments.
With this release comes several improvements:
Option<CompactString>is the same size asCompactString, wrapping in anOption<_>no longer requires additional padding- A new macro,
format_compact!which allows you to create aCompactStringjust like you would create aStringwith thestd::format!macro - A new trait,
CompactStringExt, which exports two methodsjoin_compact(seperator)andconcat_compact(), which allow you to construct aCompactStringfrom a collection of items - Implements
AsRef<OsStr>forCompactString - Various performance improvements
GitHub: https://github.com/ParkMyCar/compact\_str
crates.io: https://crates.io/crates/compact\_str
Special thanks to u/Nilstrieb, u/NobodyXu, and u/CAD97 for their contributions! 🎉