pub struct TreePath {
    pub path: Vec<usize>,
}
Expand description

Describe the path traversal of a Node starting from the root node

The figure below shows node_idx in a depth first traversal.

           .─.
          ( 0 )
           `-'
          /   \
         /     \
        /       \
       ▼         ▼
      .─.         .─.
     ( 1 )       ( 4 )
      `-'         `-'
     /  \          | \ '.
    /    \         |  \  '.
   ▼      ▼        |   \   '.
 .─.      .─.      ▼    ▼     ▼
( 2 )    ( 3 )    .─.   .─.   .─.
 `─'      `─'    ( 5 ) ( 6 ) ( 7 )
                  `─'   `─'   `─'

The figure below shows the index of each child node relative to their parent node

            .─.
           ( 0 )
            `-'
           /   \
          /     \
         /       \
        ▼         ▼
       .─.         .─.
      ( 0 )       ( 1 )
       `-'         `-'
      /  \          | \ '.
     /    \         |  \  '.
    ▼      ▼        |   \   '.
  .─.      .─.      ▼    ▼     ▼
 ( 0 )    ( 1 )    .─.   .─.   .─.
  `─'      `─'    ( 0 ) ( 1 ) ( 2 )
                   `─'   `─'   `─'

The equivalent idx and path are as follows:

   0 = []
   1 = [0]
   2 = [0,0]
   3 = [0,1]
   4 = [1]
   5 = [1,0]
   6 = [1,1]
   7 = [1,2]

Fields

path: Vec<usize>

An array of child index at each level of the dom tree. The children of the nodes at each child index is traverse at each traversal the first element of path is removed until the path becomes empty. If the path has become empty the node is said to be found.

Empty path means root node

Implementations

create a TreePath with node index node_idx and traversal path path

create a TreePath which starts at empty vec which is the root node of a DOM tree

add a path node idx

create a new TreePath with an added node_index This is used for traversing into child elements

remove first node index of this treepath Everytime a node is traversed, the first element should be removed until no more index is in this path

pluck the next in line node index in this treepath

returns tree if the path is empty This is used for checking if the path has been traversed

find the node using the path of this tree path

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.