pub struct Node<T> { /* private fields */ }
Expand description
Represents a single node in a tree structure.
Each node contains:
- data: A payload of generic type
T
. - children: A list of indices referring to its child nodes.
- parent: An optional index referring to its parent node (or
None
if the node is a root).
Normally, you should use the Tree::add_node
and
Tree::add_child
methods to create nodes and add them to the tree. There’s no need to
address Node
directly in most cases.
Implementations§
Source§impl<T> Node<T>
impl<T> Node<T>
Sourcepub fn new(data: T) -> Self
pub fn new(data: T) -> Self
Creates a new node with the given data. Normally, you should use the Tree::add_node
and
Tree::add_child
methods to create nodes and add them to the tree. There’s no need to
address Node
directly in most cases.
§Parameters
data
: The data to associate with this node.
§Returns
A new Node
instance.
§Example
use easy_tree::Node;
let node = Node::new("example");
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Node<T>where
T: Freeze,
impl<T> RefUnwindSafe for Node<T>where
T: RefUnwindSafe,
impl<T> Send for Node<T>where
T: Send,
impl<T> Sync for Node<T>where
T: Sync,
impl<T> Unpin for Node<T>where
T: Unpin,
impl<T> UnwindSafe for Node<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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