pub struct TreeNode<T> {
pub name: String,
pub data: Option<T>,
pub children: Vec<TreeNode<T>>,
}Expand description
Generic tree node that can hold any data type
Represents a node in a hierarchical tree structure. Each node has a name, optional data, and a list of child nodes.
Fields§
§name: StringName of the node (e.g., file name, directory name)
data: Option<T>Optional data associated with the node (None for directory nodes)
children: Vec<TreeNode<T>>Child nodes
Implementations§
Source§impl<T> TreeNode<T>
impl<T> TreeNode<T>
Sourcepub const fn new(name: String, data: Option<T>) -> Self
pub const fn new(name: String, data: Option<T>) -> Self
Create a new tree node
§Arguments
name- Name of the nodedata- Optional data associated with the node
§Examples
use tree_fmt::TreeNode;
// Create a file node with data
let file = TreeNode::new( "main.rs".to_string(), Some( 100u64 ) );
// Create a directory node without data
let dir : TreeNode< u64 > = TreeNode::new( "src".to_string(), None );Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TreeNode<T>where
T: Freeze,
impl<T> RefUnwindSafe for TreeNode<T>where
T: RefUnwindSafe,
impl<T> Send for TreeNode<T>where
T: Send,
impl<T> Sync for TreeNode<T>where
T: Sync,
impl<T> Unpin for TreeNode<T>where
T: Unpin,
impl<T> UnwindSafe for TreeNode<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