$ id-arena
v2.3.0MAJOR UPDATEA simple, id-based arena.
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));
Links • https://crates.io/crates/id-arena • https://github.com/SimonSapin/rust-typed-arena/ • https://github.com/fitzgen/generational-arena • https://crates.io/crates/rayon
Release info
Release version: N/A
Release description N/A
Code Examples N/A
Minor update: 2.2.1 → 2.3.0
$ DOWNLOADS TREND
$ VERSION HISTORY
$ LINKS
$ INSTALL
cargo add id-arenaOr add to Cargo.toml: id-arena = "2.3.0"