[−][src]Enum structures::tree::Tree
Binary Tree
Examples
use structures::tree::{TraverseOrder, Tree}; let tree = Tree::branch(1, Tree::leaf(2), Tree::leaf(3)); println!("{:#?}", tree); println!("{:?}", tree.iter(TraverseOrder::InOrder).collect::<Vec<_>>());
Variants
Empty
Branch(T, Box<Self>, Box<Self>)
Methods
impl<T> Tree<T>
[src]
pub fn empty() -> Self
[src]
pub fn leaf(v: T) -> Self
[src]
pub fn branch(v: T, l: Self, r: Self) -> Self
[src]
pub fn left(&self) -> Option<&Self>
[src]
pub fn right(&self) -> Option<&Self>
[src]
pub fn value(&self) -> Option<&T>
[src]
pub fn iter(&self, order: TraverseOrder) -> impl Iterator<Item = &T>
[src]
pub fn traverse(&self, order: TraverseOrder, f: &mut dyn FnMut(&T))
[src]
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,