Skip to main content

TreeNode

Struct TreeNode 

Source
pub struct TreeNode {
    pub children: IndexMap<String, Self>,
    pub is_leaf: bool,
}
Expand description

A structure representing a node in a tree.

This structure is used to represent a node in a tree. Each node has a collection of children, which are also nodes. The IndexMap ensures that the children are ordered in the order they were inserted.

§Fields

  • children - An IndexMap where the keys are String and the values are TreeNode. This represents the children of the node.
  • is_leaf - A boolean flag that indicates whether the node is a leaf node (i.e., it has no children).

Fields§

§children: IndexMap<String, Self>

The children of this node.

§is_leaf: bool

Whether this node is a leaf (has no children).

Implementations§

Source§

impl TreeNode

Source

pub fn new() -> Self

Creates a new TreeNode.

Source

pub fn add_path<I>(&mut self, parts: I)
where I: IntoIterator, I::Item: AsRef<str>,

Adds a path to the tree structure.

The path is split into parts, and each part is added as a node in the tree. If a part already exists, it is reused.

§Type Parameters
  • I - An iterator over string-like items that can be referenced as strings.
§Arguments
  • parts - An iterable of path components to add to the tree.

Trait Implementations§

Source§

impl Default for TreeNode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.