fn check_black_depth<T>(node: &RBTreeNode<T>) -> usize {
            let child_depth = match (&node.right, &node.left) {
                (&Some(ref right), &Some(ref left)) => {
                    let child_depth = check_black_depth(&right);
                    assert_eq!(child_depth, check_black_depth(&left));
                    child_depth
                }
                (&None, &Some(ref child)) |
                (&Some(ref child), &None) => {
                    let child_depth = check_black_depth(&child);
                    assert_eq!(child_depth, 0);
                    child_depth
                }
                _ => 0,
            };

            match node.color {
                Color::Black => 1 + child_depth,
                Color::Red => child_depth,
            }
        }
// All branches have the same number of black nodes
// (DFS saving the black depth of the first leaf seen)
All branches have the same number of black nodes
(DFS saving the black depth of the first leaf seen)
All branches have the same number of black nodes ( DFS saving the black depth of the first leaf seen )
fn check_black_depth<T>(node: &RBTreeNode<T>) -> usize {
            let child_depth = match (&node.right, &node.left) {
                (&Some(ref right), &Some(ref left)) => {
                    let child_depth = check_black_depth(&right);
                    assert_eq!(child_depth, check_black_depth(&left));
                    child_depth
                }
                (&None, &Some(ref child)) |
                (&Some(ref child), &None) => {
                    let child_depth = check_black_depth(&child);
                    assert_eq!(child_depth, 0);
                    child_depth
                }
                _ => 0,
            };
            match node.color {
                Color::Black => 1 + child_depth,
                Color::Red => child_depth,
            }
        }
fn check_black_depth < T > ( node : & RBTreeNode < T > ) -> usize { let child_depth = match ( & node . right , & node . left ) { ( & Some ( ref right ) , & Some ( ref left ) ) => { let child_depth = check_black_depth ( & right ) ; assert_eq ! ( child_depth check_black_depth ( left ) ) ; child_depth } ( & None , & Some ( ref child ) ) | ( & Some ( ref child ) , & None ) => { let child_depth = check_black_depth ( & child ) ; assert_eq ! ( child_depth 0 ) ; child_depth } _ => 0 , } ; match node . color { Color :: Black => 1 + child_depth , Color :: Red => child_depth , } }
All branches have the same number of black nodes
(DFS saving the black depth of the first leaf seen)
All branches have the same number of black nodes ( DFS saving the black depth of the first leaf seen )
node
&RBTreeNode<T>
node
&RBTreeNode<T>