-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* README updated and image added * README and manifest updated * StackVec replaced by LocalVec * diagram updated * travis badge added
- Loading branch information
Showing
6 changed files
with
32 additions
and
31 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
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 |
---|---|---|
@@ -1,30 +1,31 @@ | ||
# `stack_vec` | ||
# `local_vec` | ||
|
||
A *fixed-capacity* vector allocated on the stack. | ||
|
||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | ||
[![Build Status](https://app.travis-ci.com/m-rinaldi/stack_vec.svg?branch=main)](https://app.travis-ci.com/m-rinaldi/stack_vec) | ||
|
||
[![Build Status](https://app.travis-ci.com/m-rinaldi/local_vec.svg?branch=main)](https://app.travis-ci.com/m-rinaldi/local_vec) | ||
|
||
--- | ||
|
||
`stack_vec::StackVec` is a *fixed-capacity* vector, i.e., its *size* or *length* increases and decreases as elements are pushed into and popped from the vector, respectively. However, its *capacity* remains always the same. | ||
`local_vec::LocalVec` is a *fixed-capacity* vector, i.e., its *size* or *length* increases and decreases as elements are pushed into and popped from the vector, respectively. However, its *capacity* remains always the same. | ||
|
||
`StackVec`'s elements reside inside it: | ||
`LocalVec`'s elements reside inside it: | ||
|
||
use stack_vec::StackVec; | ||
let mut vec = StackVec::<_, 4>::new(); | ||
use local_vec::LocalVec; | ||
let mut vec = LocalVec::<_, 4>::new(); | ||
vec.push(3); | ||
vec.push(7); | ||
|
||
`vec` contents in the code above are graphically represented as: | ||
|
||
<p align="center"> | ||
<img src="img/StackVec.png"> | ||
<img src="img/LocalVec.png"> | ||
</p> | ||
|
||
|
||
In contrast, [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html) allocates a buffer on the heap and contains a pointer to that buffer instead of the buffer itself. | ||
|
||
|
||
The capacity of a `StackVec` must be determined at compile-time as a constant argument. | ||
The capacity of a `LocalVec` must be determined at compile-time as a constant argument. | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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