Skip to main content

Crate fastarena

Crate fastarena 

Source
Expand description

A zero-dependency bump-pointer arena allocator with RAII transactions, nested savepoints, and ArenaVec.

§Features

  • O(1) amortised allocation — bump pointer advance with a single bounds check
  • Checkpoint / rewind — snapshot arena state in O(1), undo allocations
  • RAII transactions — auto-rollback on drop, explicit commit via mem::forget
  • Transaction budget — cap arena bytes per transaction (tracks inline sizes only; heap allocations inside values are not counted)
  • Zero-cost reset — reuse all allocated blocks without OS calls
  • ArenaVec<T> — append-only growable vector backed by arena memory

§Quick Start

use fastarena::Arena;

let mut arena = Arena::new();
let x = arena.alloc(42u64);
let s = arena.alloc_str("hello");
arena.reset(); // zero-cost reset

§Feature Flags

FlagDefaultDescription
drop-trackingOffRun destructors in LIFO order on reset/rewind

Macros§

arenavec
Creates an ArenaVec backed by the given arena.

Structs§

Arena
A bump-pointer arena allocator with RAII transactions, checkpoint/rewind, and zero-cost reset/reuse.
ArenaStats
A snapshot of arena memory usage returned by super::allocator::Arena::stats.
ArenaVec
An append-only growable vector backed by arena memory.
ArenaVecIntoIter
Owning iterator over an ArenaVec. Drains elements front-to-back and drops any remaining elements (in LIFO order) when the iterator itself is dropped.
Checkpoint
An opaque snapshot of arena state used by Arena::rewind.
Transaction
A scoped RAII transaction over an Arena.
TxnDiff
Allocation metrics for a single transaction scope, returned by Transaction::diff.

Enums§

TryReserveError
Error returned by ArenaVec::try_reserve when allocation fails.
TxnStatus
Outcome of Transaction::commit or Transaction::rollback.