#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

#2 in Data structures

Download history 240969/week @ 2019-12-17 165473/week @ 2019-12-24 196703/week @ 2019-12-31 279981/week @ 2020-01-07 270841/week @ 2020-01-14 265904/week @ 2020-01-21 285985/week @ 2020-01-28 287651/week @ 2020-02-04 266765/week @ 2020-02-11 265993/week @ 2020-02-18 283679/week @ 2020-02-25 278743/week @ 2020-03-03 273758/week @ 2020-03-10 284630/week @ 2020-03-17 289222/week @ 2020-03-24 265404/week @ 2020-03-31

967,989 downloads per month
Used in 7,527 crates (334 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