merkle: add parent() helper function on NodeIndex
This commit is contained in:
parent
ee20a49953
commit
8e594963d2
1 changed files with 8 additions and 0 deletions
|
@ -97,6 +97,14 @@ impl NodeIndex {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the parent of the current node. This is the same as [`Self::move_up()`], but returns
|
||||||
|
/// a new value instead of mutating `self`.
|
||||||
|
pub const fn parent(mut self) -> Self {
|
||||||
|
self.depth = self.depth.saturating_sub(1);
|
||||||
|
self.value >>= 1;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
// PROVIDERS
|
// PROVIDERS
|
||||||
// --------------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue