#small #vec #vector #stack #no_std

no-std smallvec

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

21 releases (2 stable)

✓ Uses Rust 2018 edition

1.1.0 Dec 20, 2019
1.0.0 Nov 3, 2019
0.6.13 Nov 5, 2019
0.6.10 Jun 10, 2019
0.1.5 Jun 30, 2015

#4 in Data structures

Download history 143967/week @ 2019-10-04 138402/week @ 2019-10-11 143250/week @ 2019-10-18 164022/week @ 2019-10-25 180009/week @ 2019-11-01 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 257929/week @ 2020-01-10

805,374 downloads per month
Used in 6,643 crates (277 directly)

MIT/Apache

77KB
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