simplify EvalTree::next
This commit is contained in:
parent
37263f983a
commit
0748b30593
@ -48,18 +48,22 @@ enum EvalTree<'a> {
|
||||
type Oet<'a> = Option<EvalTree<'a>>;
|
||||
|
||||
impl<'a> EvalTree<'a> {
|
||||
fn _next_composite(self, other: Box<Self>) -> Self {
|
||||
match self {
|
||||
Self::Atom(f) => match f.next() {
|
||||
Some(newleft) => Self::Composite(Box::new(newleft), other),
|
||||
None => *other,
|
||||
},
|
||||
Self::Composite(etll, etlr) => {
|
||||
Self::Composite(etll, Box::new(Self::Composite(etlr, other)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn next(self) -> Oet<'a> {
|
||||
match self {
|
||||
Self::Atom(f) => f.next(),
|
||||
Self::Composite(etl, etr) => match *etl {
|
||||
Self::Atom(f) => match f.next() {
|
||||
Some(newleft) => Some(Self::Composite(Box::new(newleft), etr)),
|
||||
None => Some(*etr),
|
||||
},
|
||||
Self::Composite(etll, etlr) => {
|
||||
Some(Self::Composite(etll, Box::new(Self::Composite(etlr, etr))))
|
||||
}
|
||||
},
|
||||
Self::Composite(etl, etr) => Some(etl._next_composite(etr)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user