Given this BST struct:
pub enum BST{
Nil,
Node{
k: i32,
l: Box<BST>,
r: Box<BST>,
}
}
How can a function be programmed such that it gives the minimum element of the BST?
I tried some things, my latest attempt is:
fn min(&mut self) -> &mut BST{
match self {
BST::Nil => self,
BST::Node{ l, ..} =>
match **l {
BST::Nil => self,
BST::Node{..} => l.min(),
}
}
}
however this doesnt work, the purpose of the min function is to work on BST deletions.