Walking

Trait Walking 

Source
pub trait Walking:
    HasParent<Node = Self>
    + NodeEquality
    + Clone {
    // Provided methods
    fn depth(&self) -> usize { ... }
    fn walk_up(&self, steps: usize) -> Option<Self> { ... }
    fn root(&self) -> Self { ... }
    fn lca_with(&self, other: &Self) -> Option<Self> { ... }
}
Expand description

Defines the walking trait of tree-like structure.

Provided Methods§

Source

fn depth(&self) -> usize

Gets the depth of this node in comparison to the root.

§Returns

The depth of this node in comparison to the root.

Source

fn walk_up(&self, steps: usize) -> Option<Self>

Walks up the tree by a given number of steps.

§Arguments
  • steps - The number of steps to traverse upward.
§Returns

The ancestor Node or None if it does not exist (root reached before).

Source

fn root(&self) -> Self

Finds the root of this node.

§Returns

The root Node.

Source

fn lca_with(&self, other: &Self) -> Option<Self>

Finds the lowest common ancestor with another Node.

§Arguments.
  • other: The other Node to find the lca with.
§Returns

The lowest common ancestor Node or None if it does not exist.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Walking for T
where T: HasParent<Node = T> + NodeEquality + Clone,