[][src]Crate max_size_vec

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]);
}

Structs

Drain

Used for draining elements out of a max-sized vector.

MaxSizeVec

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).

MaxSizeVecIter

An iterator used for the iterator method of a max-sized iterator.