Add accessors to private frontier elements.

This commit is contained in:
Kris Nuttycombe 2021-07-08 13:06:40 -06:00
parent 909f0d6224
commit 6d527c7a67
1 changed files with 14 additions and 0 deletions

View File

@ -158,6 +158,14 @@ impl<H> NonEmptyFrontier<H> {
pub fn size(&self) -> usize { pub fn size(&self) -> usize {
self.position.0 + 1 self.position.0 + 1
} }
pub fn leaf(&self) -> &Leaf<H> {
&self.leaf
}
pub fn ommers(&self) -> &Vec<H> {
&self.ommers
}
} }
impl<H: Clone> NonEmptyFrontier<H> { impl<H: Clone> NonEmptyFrontier<H> {
@ -338,6 +346,12 @@ impl<H, const DEPTH: u8> Frontier<H, DEPTH> {
} }
} }
/// Return the wrapped NonEmptyFrontier reference, or None if
/// the frontier is empty.
pub fn value(&self) -> Option<&NonEmptyFrontier<H>> {
self.frontier.as_ref()
}
/// Returns the position of latest leaf appended to the frontier, /// Returns the position of latest leaf appended to the frontier,
/// if the frontier is nonempty. /// if the frontier is nonempty.
pub fn position(&self) -> Option<Position> { pub fn position(&self) -> Option<Position> {