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§
Traits§
- Idx
- Newtype ID trait. Implement for any newtype wrapping a small
non-negative integer (
u32is the conventional choice).