Skip to main content

Module arena

Module arena 

Source
Expand description

Generic index-based arena for AST nodes.

Replaces Box<T> with a Copy integer handle (Id<T>) into a flat Vec<T> owned by an Arena<T>. Every Id<T> is tagged with the id of the arena it was allocated from, so using it against the wrong arena panics immediately at the access site instead of silently reading unrelated data or panicking later with a confusing out-of-bounds error.

Structs§

Arena
Flat backing store for T, indexed by Id<T>.
Id
A typed, Copy handle into a specific Arena<T>.

Statics§

NEXT_ARENA_ID 🔒
Global counter handing out a unique id to every Arena<T> that’s ever constructed, so Id<T>s can be checked against their origin arena.