Skip to main content

Module index_vec

Module index_vec 

Source
Expand description

IndexVec<I, V> — dense ID → value table.

Strongly-typed Vec indexed by a newtype ID instead of usize. Use for “every entity gets a sequentially-allocated ID” patterns: SymbolId → SymbolData, NodeId → NodeData, TypeId → TypeInfo, BlockId → BasicBlock. Lookup is O(1) array access; iteration is deterministic insertion order.

No hashing, no probing, no allocator overhead beyond Vec growth. For dense IDs this is strictly better than BTreeMap<u32, V>: constant-time lookup, contiguous memory, zero indirection.

Structs§

IndexVec

Traits§

Idx
Newtype ID trait. Implement for any newtype wrapping a small non-negative integer (u32 is the conventional choice).