pub fn depth_first_search<'a, R, V>(&'a self, visit: &mut V) -> R
    where
        V: FnMut(&'a Tree<T>, &'a Node<T>, usize) -> SearchResult<R>,
        R: Default,
    {
        let mut pending = Vec::new();
        pending.push((self.root, 0));

        while let Some((n, level)) = pending.pop() {
            let node = self.get(n).unwrap();
            if let SearchResult::Return(r) = visit(self, node, level) {
                return r;
            }
            pending.extend(node.children().iter().map(|c| (*c, level + 1)));
        }
        // no-one returned
        R::default()
    }
/// Perform a depth-first search of the tree nodes.
Perform a depth-first search of the tree nodes.
Perform a depth - first search of the tree nodes .
pub fn depth_first_search<'a, R, V>(&'a self, visit: &mut V) -> R
    where
        V: FnMut(&'a Tree<T>, &'a Node<T>, usize) -> SearchResult<R>,
        R: Default,
    {
        let mut pending = Vec::new();
        pending.push((self.root, 0));
        while let Some((n, level)) = pending.pop() {
            let node = self.get(n).unwrap();
            if let SearchResult::Return(r) = visit(self, node, level) {
                return r;
            }
            pending.extend(node.children().iter().map(|c| (*c, level + 1)));
        }
        // no-one returned
        R::default()
    }
pub fn depth_first_search < ' a , R , V > ( & ' a self , visit : & mut V ) -> R where V : FnMut ( & ' a Tree < T > , & ' a Node < T > , usize ) -> SearchResult < R > , R : Default , { let mut pending = Vec :: new ( ) ; pending . push ( ( self . root , 0 ) ) ; while let Some ( ( n , level ) ) = pending . pop ( ) { let node = self . get ( n ) . unwrap ( ) ; if let SearchResult :: Return ( r ) = visit ( self , node , level ) { return r ; } pending . extend ( node . children ( ) . iter ( ) . map ( | c | ( * c , level + 1 ) ) ) ; } // no-one returned R :: default ( ) }
Perform a depth-first search of the tree nodes.
Perform a depth - first search of the tree nodes .
&'a self
visit
&mut V