BinaryTreesHeight::node_height_error
This commit is contained in:
parent
133a3c23e5
commit
a1d836ed54
@ -135,6 +135,7 @@ pub trait BinaryTreesMutable<'a>: BinaryTreesEmpty<'a> + BinaryTreesTreeOf<'a> {
|
|||||||
pub trait BinaryTreesHeight<'a>: BinaryTrees<'a> {
|
pub trait BinaryTreesHeight<'a>: BinaryTrees<'a> {
|
||||||
fn height(&self, tree: &Self::Tree) -> u64;
|
fn height(&self, tree: &Self::Tree) -> u64;
|
||||||
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T>;
|
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T>;
|
||||||
|
fn node_height_error<T: 'a>(&self) -> BTWrap<'a, Self, T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait BinaryTreesTryJoin<'a>: BinaryTrees<'a> {
|
pub trait BinaryTreesTryJoin<'a>: BinaryTrees<'a> {
|
||||||
|
@ -163,6 +163,10 @@ impl<'a, BT: BinaryTreesUnbalanced<'a>> BinaryTreesHeight<'a> for BalancedTrees<
|
|||||||
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
||||||
self.0.leaf_height_error(height)
|
self.0.leaf_height_error(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn node_height_error<T: 'a>(&self) -> BTWrap<'a, Self, T> {
|
||||||
|
self.0.node_height_error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, BT: BinaryTreesUnbalanced<'a> + BinaryTreesTryJoin<'a>> BinaryTreesTryJoin<'a>
|
impl<'a, BT: BinaryTreesUnbalanced<'a> + BinaryTreesTryJoin<'a>> BinaryTreesTryJoin<'a>
|
||||||
|
@ -172,6 +172,10 @@ impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesHeight<'a>> BinaryTreesHeight<
|
|||||||
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
||||||
self.0.leaf_height_error(height)
|
self.0.leaf_height_error(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn node_height_error<T: 'a>(&self) -> BTWrap<'a, Self, T> {
|
||||||
|
self.0.node_height_error()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesTryJoin<'a>> BinaryTreesTryJoin<'a>
|
impl<'a, BT: BinaryTreesBindable<'a> + BinaryTreesTryJoin<'a>> BinaryTreesTryJoin<'a>
|
||||||
|
@ -122,6 +122,10 @@ impl<'a, A: 'a + Ord + Clone> BinaryTreesHeight<'a> for Trees<A> {
|
|||||||
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
fn leaf_height_error<T: 'a>(&self, height: u64) -> BTWrap<'a, Self, T> {
|
||||||
panic!("leaf height error: {height}.")
|
panic!("leaf height error: {height}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn node_height_error<T: 'a>(&self) -> BTWrap<'a, Self, T> {
|
||||||
|
panic!("node with height 0.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, A: 'a + Ord + Clone> BinaryTreesEmpty<'a> for Trees<A> {
|
impl<'a, A: 'a + Ord + Clone> BinaryTreesEmpty<'a> for Trees<A> {
|
||||||
|
Loading…
Reference in New Issue
Block a user