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

64 points park_my_car

Hey folks, I'm announcing version 0.3 of a library I've been working on called compact_str! This library exports a single struct, CompactStr, which is a string type that stores short strings (strings <= 24 bytes) on the stack, and transparently stores longer strings on the heap. Aka a "small string optimization".

This release comes with several improvements to the library including:

  • Mutability, you can now "push" and "pop" characters onto the string
  • Ergonomics, the FromIterator and Extend traits have been implemented, which make it easier to construct and update a CompactStr
  • Performance, creating a CompactStr is now faster than ever!
  • Efficiency, you can now inline strings that are 24 characters long, without the previous limitation of the first character needing to be ASCII
  • Testing, expanded testing across more platforms, added fuzz testing with libFuzzer and AFL++, and added testing with miri

GitHub: https://github.com/ParkMyCar/compact_str