local_vec
A fixed-capacity vector allocated on the stack.
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.
LocalVec
's elements reside inside it:
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:
In contrast, Vec
allocates a buffer on the heap and contains a pointer to that buffer instead of the buffer itself.
The capacity of a LocalVec
must be determined at compile-time as a constant argument.