#small #vec #vector #stack #no_std

no-std smallvec

‘Small vector’ optimization: store up to a small number of items on the stack

22 releases (3 stable)

✓ Uses Rust 2018 edition

1.2.0 Jan 29, 2020
1.1.0 Dec 20, 2019
1.0.0 Nov 3, 2019
0.6.13 Nov 5, 2019
0.1.5 Jun 30, 2015

#3 in Data structures

Download history 186363/week @ 2019-11-08 189832/week @ 2019-11-15 233028/week @ 2019-11-22 236515/week @ 2019-11-29 256854/week @ 2019-12-06 250761/week @ 2019-12-13 179401/week @ 2019-12-20 185963/week @ 2019-12-27 255481/week @ 2020-01-03 282504/week @ 2020-01-10 261946/week @ 2020-01-17 275287/week @ 2020-01-24 288143/week @ 2020-01-31 277167/week @ 2020-02-07 242981/week @ 2020-02-14

967,989 downloads per month
Used in 7,091 crates (301 directly)

MIT/Apache

78KB
2K SLoC

rust-smallvec

Documentation

Release notes

"Small vector" optimization for Rust: store up to a small number of items on the stack

Example

use smallvec::{SmallVec, smallvec};
    
// This SmallVec can hold up to 4 items on the stack:
let mut v: SmallVec<[i32; 4]> = smallvec![1, 2, 3, 4];

// It will automatically move its contents to the heap if
// contains more than four items:
v.push(5);

// SmallVec points to a slice, so you can use normal slice
// indexing and other methods to access its contents:
v[0] = v[1] + v[2];
v.sort();

Dependencies