[][src]Struct text_trees::TreeNode

pub struct TreeNode<T> where
    T: Display
{ /* fields omitted */ }

Denotes a node in the tree, and any node can be the root of a tree when output. The generic parameter T must implement Display which is used to generate the label for each node in the output.

Note that From<T> is implemented allowing a nice short-cut for node creation, and From<&T> is also implemented for types that also implement Clone.

Implementations

impl<T> TreeNode<T> where
    T: Display
[src]

pub fn new(data: T) -> Self[src]

Construct a new tree node with the provided data value.

pub fn with_children(data: T, children: impl Iterator<Item = T>) -> Self where
    T: Sized
[src]

Construct a new tree node with the provided data value and an iterator that provides child data items.

pub fn with_child_nodes(
    data: T,
    children: impl Iterator<Item = TreeNode<T>>
) -> Self where
    T: Sized
[src]

Construct a new tree node with the provided data value and an iterator that provides pre-constructed TreeNode values as child nodes.

pub fn data(&self) -> &T[src]

Return a reference to the data item for this node.

pub fn label(&self) -> String[src]

Return the label for this node.

pub fn has_children(&self) -> bool[src]

Returns true if this node has child nodes, else false.

pub fn children(&self) -> impl Iterator<Item = &TreeNode<T>>[src]

Returns an iterator that will return all the child nodes.

pub fn push(&mut self, data: T)[src]

Push a new data item into the list of children.

pub fn push_node(&mut self, child: TreeNode<T>)[src]

Push a new pre-constructed TreeNode into the list of children.

pub fn extend<V>(&mut self, children: impl Iterator<Item = T>)[src]

Extend the list of children with each data item from the provided iterator.

pub fn to_string_with_format(&self, format: &TreeFormatting) -> Result<String>[src]

Return a string containing the generated tree text formatted according to the provided format settings.

Note: in effect Display::fmt calls this method with default formatting.

pub fn write(&self, to_writer: &mut impl Write) -> Result<()> where
    T: Display
[src]

Write this tree to the provided implementation of std::io::Write with default formatting.

pub fn write_with_format(
    &self,
    to_writer: &mut impl Write,
    format: &TreeFormatting
) -> Result<()> where
    T: Display
[src]

Write this tree to the provided implementation of std::io::Write with the provided format settings.

Trait Implementations

impl<T: Clone> Clone for TreeNode<T> where
    T: Display
[src]

impl<T: Debug> Debug for TreeNode<T> where
    T: Display
[src]

impl<T> Display for TreeNode<T> where
    T: Display
[src]

impl<T, '_> From<&'_ T> for TreeNode<T> where
    T: Display + Clone
[src]

impl<'_> From<&'_ str> for TreeNode<String>[src]

impl<T> From<T> for TreeNode<T> where
    T: Display
[src]

impl<T> PartialEq<TreeNode<T>> for TreeNode<T> where
    T: Display + PartialEq
[src]

Auto Trait Implementations

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.