ParkMyCar / compact_str

A memory efficient string type that can store up to 24* bytes on the stack
MIT License
652 stars 47 forks source link

api: Add CompactString::into_bytes #258

Closed ParkMyCar closed 1 year ago

ParkMyCar commented 1 year ago

This PR adds a new API CompactString::into_bytes which consumes a CompactString, returning a byte vector, just like the String::into_bytes method.

A difference though is CompactString::into_bytes returns a SmallVec which allows us to avoid needing to allocate, by re-using the underlying buffer from the CompactString