pub struct CoveringNode<'a> { /* private fields */ }Expand description
The node with a minimal range that fully contains the search range.
Implementations§
Source§impl<'a> CoveringNode<'a>
impl<'a> CoveringNode<'a>
Sourcepub fn from_ancestors(ancestors: Vec<AnyNodeRef<'a>>) -> Self
pub fn from_ancestors(ancestors: Vec<AnyNodeRef<'a>>) -> Self
Creates a new CoveringNode from a list of ancestor nodes.
The ancestors should be ordered from root to the covering node.
Sourcepub fn node(&self) -> AnyNodeRef<'a>
pub fn node(&self) -> AnyNodeRef<'a>
Returns the covering node found.
Sourcepub fn parent(&self) -> Option<AnyNodeRef<'a>>
pub fn parent(&self) -> Option<AnyNodeRef<'a>>
Returns the node’s parent.
Sourcepub fn find_first(
self,
f: impl Fn(AnyNodeRef<'a>) -> bool,
) -> Result<Self, Self>
pub fn find_first( self, f: impl Fn(AnyNodeRef<'a>) -> bool, ) -> Result<Self, Self>
Finds the first node that fully covers the range and fulfills the given predicate.
The “first” here means that the node closest to a leaf is returned.
Sourcepub fn find_last(self, f: impl Fn(AnyNodeRef<'a>) -> bool) -> Result<Self, Self>
pub fn find_last(self, f: impl Fn(AnyNodeRef<'a>) -> bool) -> Result<Self, Self>
Finds the last node that fully covers the range and fulfills the given predicate.
The “last” here means that after finding the “first” such node, the highest ancestor found satisfying the given predicate is returned. Note that this is not the same as finding the node closest to the root that satisfies the given predictate.
Sourcepub fn ancestors(&self) -> impl DoubleEndedIterator<Item = AnyNodeRef<'a>> + '_
pub fn ancestors(&self) -> impl DoubleEndedIterator<Item = AnyNodeRef<'a>> + '_
Returns an iterator over the ancestor nodes, starting with the node itself and walking towards the root.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for CoveringNode<'a>
impl<'a> RefUnwindSafe for CoveringNode<'a>
impl<'a> Send for CoveringNode<'a>
impl<'a> Sync for CoveringNode<'a>
impl<'a> Unpin for CoveringNode<'a>
impl<'a> UnsafeUnpin for CoveringNode<'a>
impl<'a> UnwindSafe for CoveringNode<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more