Announcing `compact_str` version 0.6! A small string optimization for Rust

192 points park_my_car

Hey folks! I'm announcing version 0.6 of compact_str, a small string optimization for Rust! This library exports a single struct CompactString which can inline strings up to 24 characters long (12 on 32-bit machines). It also exports two traits, ToCompactString and CompactStringExt, as well as a single macro format_compact!.

Along with performance improvements, this release includes implementing multiple methods for CompactString, to bring its API nearly 1:1 with String. The only exception being methods that don't have a direct port for a small string optimization, e.g. into\_bytes, or methods that aren't yet stable. A full change log can be found here.

Huge shout out to @Kijewski for implementing many of the new methods, and to @neoeinstein and @njaard for their PRs too!

​

GitHub: https://github.com/ParkMyCar/compact\_str

crates.io: https://crates.io/crates/compact\_str