diff --git a/src/func/instances/stackless.rs b/src/func/instances/stackless.rs index 5d257fd..280ab07 100644 --- a/src/func/instances/stackless.rs +++ b/src/func/instances/stackless.rs @@ -47,15 +47,30 @@ enum EvalTree<'a> { type Oet<'a> = Option>; +struct Temp; + +impl Atom for Temp { + fn next<'t>(self: Box) -> Oet<'t> + where + Self: 't, + { + unreachable!() + } +} + impl<'a> EvalTree<'a> { - fn _next_composite(self, other: Box) -> Self { - match self { + fn _next_composite(mut self: Box, other: Box) -> Self { + match *self { Self::Atom(f) => match f.next() { - Some(newleft) => Self::Composite(Box::new(newleft), other), + Some(newleft) => { + *self = newleft; + Self::Composite(self, other) + } None => *other, }, Self::Composite(etll, etlr) => { - Self::Composite(etll, Box::new(Self::Composite(etlr, other))) + *self = Self::Composite(etlr, other); + Self::Composite(etll, self) } } }