Arena allocator - Rust
Fixed-capacity bump-pointer arena with reset() for per-request reuse. Allocate is a single cursor bump; reset is constant-time. Auto-grow is opt-in via the growable feature.
Part of the submillisecond.com cookbook. Zero external dependencies; std only.
Install
[]
= "0.5"
Opt-in features layer focused capability over the fixed-capacity base:
typed, growable, stats, aligned, freelist.
Quickstart
Public API
pub struct Bumppub fn new() -> Selfpub fn with_capacity(capacity_bytes: usize) -> Selfpub fn alloc_copy<T: Copy>(&mut self, value: T) -> &mut Tpub fn try_alloc_copy<T: Copy>(&mut self, value: T) -> Option<&mut T>pub fn alloc_raw(&mut self, layout: Layout) -> *mut u8pub fn try_alloc_raw(&mut self, layout: Layout) -> Option<*mut u8>pub fn reset(&mut self)pub fn used(&self) -> usizepub fn capacity(&self) -> usizepub fn total_capacity(&self) -> usize(alias forcapacity)
Files
src/lib.rs- implementation.tests/- integration tests; correctness, edge cases, property/stress.examples/demo.rs- stdout walkthrough.examples/perf_main.rs- bench entry (behind theharnessfeature).
License
Dual-licensed under MIT OR Apache-2.0.