Announcing `compact_str` version 0.7! A small string optimization for Rust
Hey folks! I'm announcing version 0.7 of compact_str, a small string optimization for Rust! This library exports a single struct CompactString which can inline strings up to 24 bytes long (12 on 32-bit machines). It also exports two traits, ToCompactString and CompactStringExt, as well as a single macro format_compact!.
The most noteworthy change in this release is a refactoring to allow for use of branchless instructions when accessing the string. Whether you have an inline string or a string on the heap, accessing the content no longer requires branching, and should be just as fast as std::string::String.
Other changes in this release are:
- Eagerly inline strings when converting
From<String>andFrom<Box<str>> - New
smallvecfeature which enables theCompactString::into_bytes() -> SmallVecAPI - Implementation of additional traits to make
CompactStringmore ergonomic - ... and more! Please see the
CHANGELOGfor more detail
Special thanks to u/kijewski_, u/NobodyXu, @mcronce, and @vbasky for their contributions!
GitHub: https://github.com/ParkMyCar/compact\_str
crates.io: https://crates.io/crates/compact\_str
Edit: replace "characters" with "bytes\