#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

#21 in #small-vec

Download history 138/week @ 2024-03-25 84/week @ 2024-04-01 68/week @ 2024-04-08 112/week @ 2024-04-15 45/week @ 2024-04-22 24/week @ 2024-04-29 19/week @ 2024-05-06 69/week @ 2024-05-13 91/week @ 2024-05-20 152/week @ 2024-05-27 93/week @ 2024-06-03 22/week @ 2024-06-10 65/week @ 2024-06-17 121/week @ 2024-06-24 33/week @ 2024-07-01 3/week @ 2024-07-08

225 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

~105KB