Skip to content

Commit

Permalink
allow converting RecExpr to Vec<L> (#275)
Browse files Browse the repository at this point in the history
This allows a variety of manipulation to be done without needing to
copy the nodes. For instance, applying some logic to each node to
produce a new `RecExpr` can move out of the old expressions.
  • Loading branch information
bjchambers committed Oct 4, 2023
1 parent e7845c5 commit 6340768
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ impl<L> From<Vec<L>> for RecExpr<L> {
}
}

impl<L> From<RecExpr<L>> for Vec<L> {
fn from(val: RecExpr<L>) -> Self {
val.nodes
}
}

impl<L: Language> RecExpr<L> {
/// Adds a given enode to this `RecExpr`.
/// The enode's children `Id`s must refer to elements already in this list.
Expand Down

0 comments on commit 6340768

Please sign in to comment.