Learning Topic Binary Search Tree. Option<Rc<RefCell<*>>> are the link types.
The current software works, but perhaps has available style improvements.
-
- Approach A . Successful. Rust code with explicit left and right traversal which may be multiple links. Two while loops.
-
- Approaches B,C. Failed. A member function with a bool selector to return left or right members. One while loop. The various rules of Rust did not approve of approach to the BOMU or results were defective.
Is there a way coalesce the left and right into one entity ? One while loop is preferred rather than two.
else {//this is Approach A
if flexy {
while let Some(chaser) = chasenode.clone().borrow().right.as_ref(){//
chasenode = chaser.clone();//chaser;
}
} else
{
while let Some(chaser) = chasenode.clone().borrow().left.as_ref() {
chasenode = chaser.clone();//chaser;
}
}
}
fn eitherlr(&self,switch:bool) -> link_irec{//approach B simplest
if switch {self.left.clone()} else {self.right.clone()}
}
Thanks in Advance. I can change the format of the post in necessary.