#vec #stack #vector #no-std

no-std stackvector

StackVec: vector-like facade for stack-allocated arrays

3 stable releases

Uses old Rust 2015

1.1.1 Apr 19, 2021
1.1.0 Apr 13, 2021
1.0.8 Sep 5, 2019
1.0.6 Jun 20, 2019
1.0.1 Dec 7, 2018

#2080 in Data structures

Download history 394/week @ 2024-06-17 299/week @ 2024-06-24 140/week @ 2024-07-01 220/week @ 2024-07-08 404/week @ 2024-07-15 314/week @ 2024-07-22 384/week @ 2024-07-29 296/week @ 2024-08-05 552/week @ 2024-08-12 323/week @ 2024-08-19 295/week @ 2024-08-26 346/week @ 2024-09-02 279/week @ 2024-09-09 246/week @ 2024-09-16 339/week @ 2024-09-23 545/week @ 2024-09-30

1,470 downloads per month

MIT/Apache

55KB
1.5K SLoC

rust-stackvector

Documentation

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.

License

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.36.0 (needed for mem::MaybeUninit).

Dependencies

~30KB