Skip to content

Commit

Permalink
Added fn root(&self) -> Id to RecExpr. (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonatan-reicher authored Jul 23, 2024
1 parent dae3050 commit 347326d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,11 @@ impl<L: Language> RecExpr<L> {
}
true
}

/// Get the root node of this expression. When adding a new node via `add`, it becomes the new root.
pub fn root(&self) -> Id {
Id::from(self.nodes.len() - 1)
}
}

impl<L: Language> Index<Id> for RecExpr<L> {
Expand Down

0 comments on commit 347326d

Please sign in to comment.