merkle: add parent() helper function on NodeIndex

This commit is contained in:
Qyriad 2024-11-13 15:17:40 -07:00
parent ee20a49953
commit b585f9cac6

View file

@ -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
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------