Crate copy_arena [−] [src]
A memory allocation arena specialized for types implement Copy.
An Arena
can allocate objects more efficiently than a
general-purpose allocator, but the objects cannot be
deallocated until the Arena
itself is destroyed.
To actually allocate out of an Arena
after creating it,
use its allocator()
method to create an Allocator
.
Examples
use copy_arena::Arena; let mut arena = Arena::new(); let mut allocator = arena.allocator(); let a: &mut i32 = allocator.alloc(5); let b: &mut f64 = allocator.alloc_default(); let c: &mut [u8] = allocator.alloc_slice(b"some text"); let b: &mut [usize] = allocator.alloc_slice_fn(10, |idx| idx + 1); let e: &mut [u32] = allocator.alloc_slice_default(10);
Structs
Allocator |
Allows allocation out of arena. |
Arena |
Holds the backing memory for allocated objects out of itself. |