pub struct StructureAst { /* private fields */ }Expand description
Arena-based structure AST.
Nodes are stored in a Vec indexed by NodeId. Insertion order is preserved
for deterministic canonical rendering (Rev.1 M-1).
Implementations§
Source§impl StructureAst
impl StructureAst
Sourcepub fn add_node(&mut self, kind: NodeKind) -> NodeId
pub fn add_node(&mut self, kind: NodeKind) -> NodeId
Add a node to the arena and return its assigned NodeId.
Sourcepub fn get(&self, id: NodeId) -> Option<&StructureNode>
pub fn get(&self, id: NodeId) -> Option<&StructureNode>
Get a reference to a node by ID.
Sourcepub fn get_mut(&mut self, id: NodeId) -> Option<&mut StructureNode>
pub fn get_mut(&mut self, id: NodeId) -> Option<&mut StructureNode>
Get a mutable reference to a node by ID.
Sourcepub fn remove(&mut self, id: NodeId) -> Option<StructureNode>
pub fn remove(&mut self, id: NodeId) -> Option<StructureNode>
Remove a node from the arena, returning it if it existed.
Sourcepub fn iter(&self) -> impl Iterator<Item = &StructureNode>
pub fn iter(&self) -> impl Iterator<Item = &StructureNode>
Iterate over all live nodes in arena order.
Sourcepub fn arena_raw(&self) -> &[Option<StructureNode>]
pub fn arena_raw(&self) -> &[Option<StructureNode>]
Returns a raw view of the arena including tombstone (None) slots.
Used by serialization layers that need lossless arena snapshots.
Sourcepub fn from_raw_parts(
root: NodeId,
arena: Vec<Option<StructureNode>>,
next_id: u64,
) -> Self
pub fn from_raw_parts( root: NodeId, arena: Vec<Option<StructureNode>>, next_id: u64, ) -> Self
Reconstruct a StructureAst from raw parts.
Used by deserialization layers for lossless arena restoration. The caller must ensure arena consistency (IDs match indices, etc.).
Trait Implementations§
Source§impl Clone for StructureAst
impl Clone for StructureAst
Source§fn clone(&self) -> StructureAst
fn clone(&self) -> StructureAst
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StructureAst
impl Debug for StructureAst
Auto Trait Implementations§
impl Freeze for StructureAst
impl RefUnwindSafe for StructureAst
impl Send for StructureAst
impl Sync for StructureAst
impl Unpin for StructureAst
impl UnsafeUnpin for StructureAst
impl UnwindSafe for StructureAst
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more