feat: implement inner_nodes() iterator for PartialMmr

This commit is contained in:
Bobbin Threadbare
2023-12-19 02:38:31 -08:00
committed by Bobbin Threadbare
parent 8f92f44a55
commit 9baddfd138
6 changed files with 245 additions and 42 deletions

View File

@@ -6,6 +6,9 @@
//! leaves count.
use core::num::NonZeroUsize;
// IN-ORDER INDEX
// ================================================================================================
/// Index of nodes in a perfectly balanced binary tree based on an in-order tree walk.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct InOrderIndex {
@@ -96,6 +99,18 @@ impl InOrderIndex {
}
}
// CONVERSIONS FROM IN-ORDER INDEX
// ------------------------------------------------------------------------------------------------
impl From<InOrderIndex> for u64 {
fn from(index: InOrderIndex) -> Self {
index.idx as u64
}
}
// TESTS
// ================================================================================================
#[cfg(test)]
mod test {
use super::InOrderIndex;