$ id-arena

v2.3.0MAJOR UPDATE

A simple, id-based arena.

Downloads: 23.7M
Recent: 2.9M
Versions: 9
Updated: January 14, 2026

Latest Update Summary

Crate

Name: id-arena New version: 2.3.0 Release date: 2026-01-14T21:40:46.477126Z

Crate readme

Short description A simple, id-based arena.

Long description The id-arena crate allows allocation of objects and returns an identifier for that object instead of a reference. This id-based approach is particularly useful for creating mutable graph data structures. The arena does not support deletion, which results in a straightforward implementation and faster allocation. It only supports homogeneous types and is compatible with #![no_std] environments that have the alloc crate. Additionally, it features integration with rayon for parallel iteration when activated.

Features • no_std compatibility • rayon support • homogeneous type support

Code Examples Add to Cargo.toml

 [dependencies.id-arena]
version = "2"
default-features = false

Add rayon feature

 [dependencies]
id-arena = { version = "2", features = ["rayon"] }

Basic usage

 use id_arena::{Arena, Id};

type AstNodeId = Id<AstNode>;

#[derive(Debug, Eq, PartialEq)]
pub enum AstNode {
    Const(i64),
    Var(String),
    Add {
        lhs: AstNodeId,
        rhs: AstNodeId,
    },
    Sub {
        lhs: AstNodeId,
        rhs: AstNodeId,
    },
    Mul {
        lhs: AstNodeId,
        rhs: AstNodeId,
    },
    Div {
        lhs: AstNodeId,
        rhs: AstNodeId,
    },
}

let mut ast_nodes = Arena::<AstNode>::new();

let three = ast_nodes.alloc(AstNode::Const(3));
let b = ast_nodes.alloc(AstNode::Var("b".into()));
let b_plus_three = ast_nodes.alloc(AstNode::Add {
    lhs: b,
    rhs: three,
});
let a = ast_nodes.alloc(AstNode::Var("a".into()));
let a_times_b_plus_three = ast_nodes.alloc(AstNode::Mul {
    lhs: a,
    rhs: b_plus_three,
});

assert_eq!(ast_nodes[three], AstNode::Const(3));

Linkshttps://crates.io/crates/id-arenahttps://github.com/SimonSapin/rust-typed-arena/https://github.com/fitzgen/generational-arenahttps://crates.io/crates/rayon

https://docs.rs/id-arena

Release info

Release version: N/A

Release description N/A

Code Examples N/A

Minor update: 2.2.1 → 2.3.0

$ DOWNLOADS TREND

20.6M23.7M

$ VERSION HISTORY

v2.3.0January 14, 2026
v2.2.1February 16, 2019

$ LINKS

$ INSTALL

cargo add id-arena

Or add to Cargo.toml: id-arena = "2.3.0"