#small #vec #vector #stack #no_std

no-std smallvec

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

24 releases (5 stable)

✓ Uses Rust 2018 edition

new 1.4.1 Jul 6, 2020
1.2.0 Jan 29, 2020
1.1.0 Dec 20, 2019
1.0.0 Nov 3, 2019
0.1.5 Jun 30, 2015

#2 in Data structures

Download history 279238/week @ 2020-03-16 288746/week @ 2020-03-23 289370/week @ 2020-03-30 297892/week @ 2020-04-06 308541/week @ 2020-04-13 332194/week @ 2020-04-20 335528/week @ 2020-04-27 324604/week @ 2020-05-04 358936/week @ 2020-05-11 343791/week @ 2020-05-18 341207/week @ 2020-05-25 366743/week @ 2020-06-01 362480/week @ 2020-06-08 310873/week @ 2020-06-15 304399/week @ 2020-06-22 274116/week @ 2020-06-29

1,401,447 downloads per month
Used in 5,262 crates (373 directly)

MIT/Apache

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