-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Huszagh
committed
Aug 21, 2019
1 parent
0b22f46
commit 128954b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,34 @@ rust-stackvector | |
|
||
"StackVec": vector-like facade for stack-allocated arrays. | ||
|
||
# Comparison to ArrayVec | ||
|
||
[ArrayVec](https://github.com/bluss/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. | ||
|
||
**Initialization** | ||
|
||
For initialization, ArrayVec offers only construction of an empty container (`new`), while stackvector offers initialization of: | ||
|
||
1. An empty container (`new`). | ||
2. From a vector (`from_vec`). | ||
3. From a stack-allocated array (`from_buf`). | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Alexhuszagh
Owner
|
||
|
||
**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](https://github.com/servo/rust-smallve), and like smallvec, it is dual licensed under either the MIT or Apache 2.0 license. | ||
|
Note that
ArrayVec
has 2 and 3 via (not to obvious)From
andFromIterator
API: