prealloc_ref_vec
Create temporary Vecs of references without allocating/deallocating (useful for realtime code). This crate is implemented without any unsafe code, and can be used without the standard library (#![no_std]).
Note, if the maximum capacity is known at compile time and is small enough to fit on the stack, then the same effect can be more easily achieved using arrayvec instead.
Example
use PreallocRefVec;
// Contruct the object to hold the allocation. Here we specify
// we want the data type to be slices of `f32` values.
//
// This object can be stored as a field in a struct for later use.
let capacity = 100;
let mut v_alloc: = new;
// ...
let slice_1: = ;
let slice_2: = ;
// Temporarily use the allocation to construct a Vec<&T>
// (Vec<&[f32]> in this case)
let mut tmp_vec = v_alloc.get_tmp;
// The temporary vec is always cleared when created.
assert_eq!;
// The temporary vec uses the internal allocation.
assert!;
tmp_vec.push;
tmp_vec.push;
// Dropping the temporary vec returns the allocation to be used again.
drop;
// ...
// Alternatively, a closure can be used to construct a temporary vec:
v_alloc.with_tmp;