stable-block-arena

Crates.iostable-block-arena
lib.rsstable-block-arena
version0.1.0
created_at2026-01-08 21:19:27.752574+00
updated_at2026-01-08 21:19:27.752574+00
descriptionBlock-allocated arena with stable handles that survive compaction
homepage
repository
max_upload_size
id2031103
size29,842
(solaeus)

documentation

README

stable-block-arena

Block-allocated arena with stable handles that survive compaction

Features

  • Stable handles: Removing elements doesn't invalidate handles to other elements
  • Block-based storage: Memory is allocated/deallocated in fixed-size blocks instead of per-element
  • Compaction: Reclaim memory from removed elements
  • Zero-cost abstractions: Handles are just u32 wrappers

Use Cases

  • Entity-component systems
  • Graph data structures
  • Resource managers
  • Virtual machine object pools
  • Any scenario requiring stable references with dynamic allocation

Example

use stable_block_arena::Arena;

let mut arena = Arena::new();

let hello = arena.insert("hello");
let world = arena.insert("world");

arena.remove(hello);

// Handle is still valid! 
assert_eq!(arena.get(world), Some(&"world"));

// Reclaim memory blocks from removed elements
arena.compact(|_| true);

// Handle is still valid after compaction!
assert_eq!(arena.get(world), Some(&"world"));

// Remove 'world' during compaction
arena.compact(|handle| handle != world);

// World has been removed during compaction
assert_eq!(arena.get(world), None);

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Commit count: 0

cargo fmt