Expand description

Dynamic data structures that do not require a global allocator.

The most directly useful might be a local FixedVec that requires its element to be neither Clone, Copy nor Default but is simply a normal vector on a locally borrowed chunk of raw memory. For this we will use the Bump allocator of static-alloc which loan us memory from the stack and cleans up by leaving the scope without requiring explicit deallocation. Sort of like alloca but safe and pretty.

use static_alloc::Bump;
use without_alloc::{FixedVec, alloc::LocalAllocLeakExt};

let mut pool: Bump<[usize; 16]> = Bump::uninit();
// Allocate a vector with capacity of 16 from the slab.
let mut vector = pool.fixed_vec(16).unwrap();

let mut num = 0;
// Push a mutable reference, not `Copy` nor `Clone`!
vector.push(&mut num);

*vector.pop().unwrap() = 4;

assert_eq!(num, 4);


pub use boxed::Box;
pub use fixed_vec::FixedVec;
pub use uninit::Uninit;


Allocator extension traits.
A pointer type for allocation with RAII semantics.
Contains the FixedVec implementation.
Reference counter value.
Safe abstractions around pointing at uninitialized memory without references.