picket 0.2.0

A lightweight, serde-compatible generational arena.
Documentation
  • Coverage
  • 88.46%
    23 out of 26 items documented0 out of 24 items with examples
  • Size
  • Source code size: 34.23 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.85 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • achusbyr/picket
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • achusbyr

Picket

A lightweight, serde-compatible generational arena allocator for Rust.

Crates.io Documentation

Picket provides a Vec-like data structure (Arena) where items are accessed via a stable, generational Index rather than a raw integer offset. This solves the ABA problem: if you remove an item and insert a new one in its place, old indices referencing the removed item will correctly fail to retrieve the new one.

Features

  • Lightweight: Index is 8 bytes. Option<Index> is also 8 bytes using NonZeroU32.
  • serde Support: The Arena can be serialized and deserialized through the serde feature.
  • no_std: Supports no_std environments. (std is enabled by default)

Usage

use picket::Arena;

fn main() {
    let mut arena = Arena::new();

    let texture_a = arena.insert("Texture A");
    let texture_b = arena.insert("Texture B");

    assert_eq!(arena[texture_a], "Texture A");

    arena.remove(texture_a);

    assert!(arena.get(texture_a).is_none());

    let texture_c = arena.insert("Texture C");

    assert!(arena.get(texture_a).is_none());
    assert_eq!(arena[texture_c], "Texture C");
}