https://github.com/kavirajk/stackvec
Like rust `Vec`, except backed by static memory store. No memory allocator is needed!
https://github.com/kavirajk/stackvec
Last synced: 2 months ago
JSON representation
Like rust `Vec`, except backed by static memory store. No memory allocator is needed!
- Host: GitHub
- URL: https://github.com/kavirajk/stackvec
- Owner: kavirajk
- Created: 2020-07-10T23:05:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-10T23:06:14.000Z (almost 5 years ago)
- Last Synced: 2025-01-17T21:07:58.019Z (4 months ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# StackVec
A normal `Vec`, except storage is backed by static array.Doesn't need any memory allocator(as backed by static array). And no `std` used. Useful for bare metal programming!
Created as a part of [cs140e](https://cs140e.sergio.bz/assignments/1-shell/#subphase-a-stackvec)
# Usage
```rust
let mut storage = [0u8; 1024];
let mut vec = StackVec::new(&mut storage);for i in 0..10 {
vec.push(i * i).expect("can push 1024 times");
}for (i, v) in vec.iter().enumerate() {
assert_eq!(*v, (i * i) as u8);
}let last_element = vec.pop().expect("has elements");
assert_eq!(last_element, 9 * 9);```
# Licence
MIT