1 unstable release
0.1.0 | Oct 7, 2020 |
---|
#13 in #stack-based
130KB
564 lines
Contains (rust library, 100KB) libmax_size_vec-1cc56b2f724f093c.rlib
This crate contains a vector type that has its own self-contained and stack-based allocation system. This type of vector is called a max-sized vector, and reserves a fixed amount of space at its creation. Once created, there are no elements, but the amount of elements can increase until the buffer is full. When the buffer is full, and another element is attempted to be added, a panic happens describing the error. This vector has the vast majority of vector methods and traits that aren't allocation specfic (e.g. reserve isn't a method). This crate has no dependencies other than core, and is therefore standalone and suitable for use without the standard library.
Example:
use max_size_vec::MaxSizeVec;
fn main() {
let mut x: MaxSizeVec<usize, 1024> = MaxSizeVec::new();
x.push(0usize);
x.swap_remove(0usize);
x.extend(5..10usize);
x.pop();
x.retain(|x| *x > 6);
x.drain(0..1);
x.drain(..1);
x.push(2);
x.insert(1usize, 1usize);
x.insert(0usize, 1usize);
x.remove(0usize);
assert_eq!(x, &[2, 1]);
}