Fixed-Size Arena Allocator
A minimal no-std, no-alloc arena allocator with fixed capacity.
Features
- Fixed-size: All memory pre-allocated at compile time
- No-std, no-alloc: Works in embedded environments with no heap
- Generic: Works with any
Copytype - Interior mutability: Safe access via
Cell(no runtime borrow checking overhead) - O(1) allocation: Free-list based allocation and deallocation
- Mark-and-sweep GC: Trait-based garbage collection via [
Trace] - Zero dependencies: Only uses
core::cell::Cell - Pluggable storage: Use fixed-size arrays (no-std) or
Vec(std feature)
Module Organization
The arena allocator is organized into the following modules:
- [
types] - Core types:ArenaIndex,ArenaError,ArenaResult - [
arena] - MainArenastruct and core operations - [
storage] - Storage backends:ArenaStoragetrait,ArrayStorage,VecStorage - [
generic_arena] - Generic arena that works with any storage backend - [
traits] - Extension traits:ArenaDelete,ArenaCopy,Trace - [
gc] - Garbage collection implementation - [
iter] - Iterator support - [
stats] - Statistics types:ArenaStats,GcStats
Storage Backends
The arena supports different storage backends via the [ArenaStorage] trait:
ArrayStorage<T, N>: Fixed-size array storage (default, no-std compatible)VecStorage<T>: Vector-based storage (requiresstdfeature)
The original Arena<T, N> type is a convenience alias for the fixed-size case.
For dynamic storage, use GenericArena<T, VecStorage<T>>.
Example
use ;
let arena: = new;
// Allocate nodes
let left = arena.alloc.unwrap;
let right = arena.alloc.unwrap;
let root = arena.alloc.unwrap;
// Access nodes
if let Branch = arena.get.unwrap
// Free when done
arena.free.unwrap;