#vec #vector #stack #no_std

no-std stackvector

StackVec: vector-like facade for stack-allocated arrays

9 stable releases

1.0.8 Sep 5, 2019
1.0.7 Sep 2, 2019
1.0.6 Jun 20, 2019
1.0.2 Jan 2, 2019
1.0.1 Dec 7, 2018

#62 in Data structures

Download history 4703/week @ 2019-12-10 3830/week @ 2019-12-17 2076/week @ 2019-12-24 2530/week @ 2019-12-31 5445/week @ 2020-01-07 3871/week @ 2020-01-14 4759/week @ 2020-01-21 4239/week @ 2020-01-28 4135/week @ 2020-02-04 2908/week @ 2020-02-11 3220/week @ 2020-02-18 2542/week @ 2020-02-25 3142/week @ 2020-03-03 2539/week @ 2020-03-10 1795/week @ 2020-03-17 2518/week @ 2020-03-24

18,828 downloads per month





Release notes

"StackVec": vector-like facade for stack-allocated arrays.

Comparison to ArrayVec

ArrayVec is a relatively mature stack vector implementation, using a backing array like stackvector. The main differences between ArrayVec and StackVec are in the compatibility with Vec's API, as well as the ease-of-creation.

Compatibility with Vec's API

ArrayVec includes numerous modifications from Vec's API, effectively requiring a wrapper to use it analogously to Vec. In certain situations, the extra functionality is desirable (for example, ArrayVec has push, which panics if the container exceeds the array's bounds, try_push, and push_unchecked, while stackvector only has push). In other cases, ArrayVec is missing numerous methods that simplify working with Vec. For example, ArrayVec is missing:

  1. Deduplication (dedup, dedup_by, dedup_by_key).
  2. Insert many elements (insert_many) (Non-standard).

Likewise, stackvector is missing certain convenience methods that are not present in Vec:

  1. Stack-allocated array is full (is_full).
  2. Dispose without dropping (dispose).

Version Support

Both ArrayVec and stackvector have support for Rustc versions as old as 1.20.0.


StackVector is derived from Servo's smallvec, and like smallvec, it is dual licensed under either the MIT or Apache 2.0 license.

Version Support

Stackvector has been tested on version of Rustc as low as 1.20.0 (needed for mem::ManuallyDrop).