From 6340768fbfc1665d5a1b28c39f385277c71b11c9 Mon Sep 17 00:00:00 2001 From: Ben Chambers <35960+bjchambers@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:08:25 -0700 Subject: [PATCH] allow converting `RecExpr` to `Vec` (#275) 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. --- src/language.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/language.rs b/src/language.rs index c51ae826..4b829df4 100644 --- a/src/language.rs +++ b/src/language.rs @@ -398,6 +398,12 @@ impl From> for RecExpr { } } +impl From> for Vec { + fn from(val: RecExpr) -> Self { + val.nodes + } +} + impl RecExpr { /// Adds a given enode to this `RecExpr`. /// The enode's children `Id`s must refer to elements already in this list.