#string #small-vec #stack #optimization #store

smallstring

'Small string' optimization: store small strings on the stack using smallvec

3 releases

Uses old Rust 2015

0.1.2 May 5, 2017
0.1.1 May 4, 2017
0.1.0 May 4, 2017

#18 in #small-vec

Download history 32/week @ 2023-12-10 64/week @ 2023-12-17 135/week @ 2023-12-24 64/week @ 2024-01-07 63/week @ 2024-01-14 61/week @ 2024-01-21 103/week @ 2024-01-28 81/week @ 2024-02-04 48/week @ 2024-02-11 62/week @ 2024-02-18 75/week @ 2024-02-25 66/week @ 2024-03-03 101/week @ 2024-03-10 72/week @ 2024-03-17 131/week @ 2024-03-24

373 downloads per month
Used in 2 crates

MIT license

6KB
148 lines

Small String

Create strings of any length on the stack, automatically upgrading to the heap when they become larger than the buffer. Also allows converting from a String for free (i.e. without copying to the stack even if they're small enough).

Backed by smallvec.

// Default maximum size to store on the stack: 8 bytes
let stack: SmallString = "Hello!".into();

// Reuses allocation
let heap: String = "Hello!".into();
let still_heap: SmallString = heap.into();

Dependencies

~100KB