diff --git a/src/rstd/collections/tree.rs b/src/rstd/collections/tree.rs index 014d407..4c7e10b 100644 --- a/src/rstd/collections/tree.rs +++ b/src/rstd/collections/tree.rs @@ -70,14 +70,12 @@ pub struct Tree<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>> { impl<'a, Ctx: Context<'a>, A: MentionableBase<'a, Ctx>> Tree<'a, Ctx, A> { fn validate_height(&self) -> Result<(), HeightError> { - if let Nullable::Null(_) = self.node { - if self.height != 0 { - Err(HeightError::LeafHeight(self.height))? - } - } else if self.height == 0 { - Err(HeightError::NodeHeight)? + match (&self.node, self.height) { + (Nullable::NotNull(_), 0) => Err(HeightError::NodeHeight), + (_, 0) => Ok(()), + (Nullable::Null(_), height) => Err(HeightError::LeafHeight(height)), + _ => Ok(()), } - Ok(()) } }