Trait IteratorEx

Source
pub trait IteratorEx: Iterator + Sized
where Self::Item: Node,
{ // Provided method fn build_tree(self) -> Option<Self::Item> { ... } }
Expand description

The trait extends the functionality of the standard Iterator trait by adding the build_tree method.

Provided Methods§

Source

fn build_tree(self) -> Option<Self::Item>

Builds a binary tree from an iterator of Nodes

§Arguments
  • self - the iterator of Nodes to build the tree from
§Return

The root node of the built tree, if it was successfully built.

Examples found in repository?
examples/build_tree.rs (line 33)
32fn main() {
33    let root = (0..11).map(leaf).build_tree().unwrap();
34    assert_eq!(55, root.value);
35    println!("root: {:?}", root);
36    println!("root.children: {:?}", root.children);
37}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: Iterator> IteratorEx for T
where T::Item: Node,