Skip to content

Commit

Permalink
Remove the Debug bound from Hashable
Browse files Browse the repository at this point in the history
The `Debug` bound here is handy but not required for the operations
on the trait.
  • Loading branch information
nuttycom committed Jun 5, 2023
1 parent 69c9690 commit 87007ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bridgetree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ mod tests {
assert!(!tree.append('i'.to_string()));
}

fn check_garbage_collect<H: Hashable + Clone + Ord, const DEPTH: u8>(
fn check_garbage_collect<H: Hashable + Clone + Ord + Debug, const DEPTH: u8>(
mut tree: BridgeTree<H, usize, DEPTH>,
) {
// Add checkpoints until we're sure everything that can be gc'ed will be gc'ed
Expand Down
7 changes: 5 additions & 2 deletions incrementalmerkletree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,15 @@ impl<H: Hashable, const DEPTH: u8> MerklePath<H, DEPTH> {

/// A trait describing the operations that make a type suitable for use as
/// a leaf or node value in a merkle tree.
pub trait Hashable: Sized + core::fmt::Debug {
pub trait Hashable {
fn empty_leaf() -> Self;

fn combine(level: Level, a: &Self, b: &Self) -> Self;

fn empty_root(level: Level) -> Self {
fn empty_root(level: Level) -> Self
where
Self: Sized,
{
Level::from(0)
.iter_to(level)
.fold(Self::empty_leaf(), |v, lvl| Self::combine(lvl, &v, &v))
Expand Down
2 changes: 1 addition & 1 deletion incrementalmerkletree/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ pub fn apply_operation<H, C, T: Tree<H, C>>(tree: &mut T, op: Operation<H, C>) {
}
}

pub fn check_operations<H: Hashable + Ord + Clone, C: Clone, T: Tree<H, C>>(
pub fn check_operations<H: Hashable + Ord + Clone + Debug, C: Clone, T: Tree<H, C>>(
mut tree: T,
ops: &[Operation<H, C>],
) -> Result<(), TestCaseError> {
Expand Down

0 comments on commit 87007ec

Please sign in to comment.