Forest

Struct Forest 

Source
pub struct Forest<T: NodeContent = RawNode> { /* private fields */ }
Expand description

A forest is a set of trees.

Implementations§

Source§

impl<T: NodeContent> Forest<T>

Source

pub fn new() -> Self

Create an empty forest.

Source

pub fn new_tree(&mut self, name: &str)

Create new empty tree.

§Arguments
  • name - Tree name.
§Return
  • Nothing.
Source

pub fn add_tree(&mut self, name: &str, tree: Tree<T>)

Add a tree to forest.

§Arguments
  • name - Tree name.
  • forest - Tree struct.
§Return
  • Nothing.
Source

pub fn remove_tree(&mut self, name: &str) -> Option<Tree<T>>

Remove tree from the forest.

§Arguments
  • name - Tree name.
§Return
  • An Option with the removed tree.
Source

pub fn get_tree(&self, name: &str) -> Option<&Tree<T>>

Get tree reference.

§Arguments
  • name - Tree name.
§Return
  • An Option with the tree reference.
Source

pub fn get_mut_tree(&mut self, name: &str) -> Option<&mut Tree<T>>

Get mutable tree reference.

§Arguments
  • name - Tree name.
§Return
  • An Option with the mut tree reference.
Source

pub fn iter(&self) -> Iter<'_, String, Tree<T>>

Get forest iterator.

§Return
  • Iterator, provides a tuple with tree_name<String>, tree_struct<Tree>.

Trait Implementations§

Source§

impl<T: Debug + NodeContent> Debug for Forest<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Forest<T>

§

impl<T> RefUnwindSafe for Forest<T>
where T: RefUnwindSafe,

§

impl<T> Send for Forest<T>
where T: Send,

§

impl<T> Sync for Forest<T>
where T: Sync,

§

impl<T> Unpin for Forest<T>
where T: Unpin,

§

impl<T> UnwindSafe for Forest<T>
where T: UnwindSafe,

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.