pub struct NodeId { /* private fields */ }Expand description
A unique, generation-checked identifier for an item in an Arena.
NodeId is Copy and can be freely stored, passed around, and compared.
It becomes invalid after the corresponding item is deallocated — accessing
it will return None rather than corrupted data.
§Safety
NodeId provides logical safety (stale IDs are detected) without
requiring unsafe code. The generation check prevents use-after-free at
the logical level, though it cannot prevent a malicious caller from
constructing arbitrary IDs.
Implementations§
Source§impl NodeId
impl NodeId
Sourcepub const fn from_raw_parts(index: u32, generation: u32) -> Self
pub const fn from_raw_parts(index: u32, generation: u32) -> Self
Creates a NodeId from raw index and generation values.
This is primarily intended for FFI boundaries where node IDs need to be converted to/from C-compatible representations.
§Correctness
The caller is responsible for providing valid index/generation pairs that
were originally obtained from the arena. Using arbitrary values may result
in accessing wrong nodes or getting None from arena lookups.