fn find_siblings(&self, label: &Label) -> FindSiblingsOutcome {
        if self.label == *label {
            if self.is_leaf() {
                return FindSiblingsOutcome::LeafFound(vec![]);
            } else {
                // Node labels should be unique so if we found a non-leaf node
                // of the same label, we short-circuit.
                return FindSiblingsOutcome::NonLeafNodeFound;
            }
        }

        let mut on_leaf_path = false;
        let mut sibling_hashes = vec![];
        let mut auxiliary_hashes = vec![];
        for child in self.children.iter() {
            // If we already found the leaf on this path, we still need to
            // gather siblings at this level but we don't need to recurse into
            // the children.
            if on_leaf_path {
                sibling_hashes.push(Some(child.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH)));
                continue;
            }

            match child.find_siblings(label) {
                FindSiblingsOutcome::NonLeafNodeFound => {
                    // Short circuit.
                    return FindSiblingsOutcome::NonLeafNodeFound;
                }
                FindSiblingsOutcome::LeafFound(child_aux_hashes) => {
                    // Mark that we found the leaf on this path so we should
                    // return siblings.
                    on_leaf_path = true;
                    auxiliary_hashes = child_aux_hashes;
                    // Insert a placeholder empty vector to mark where in the
                    // left -> right flow the path to the leaf was found.
                    sibling_hashes.push(None);
                }
                FindSiblingsOutcome::NotFound => {
                    // Continue to check other branches, but store all children
                    // at this level by reference, in case this is on the path
                    // to the leaf.
                    sibling_hashes.push(Some(child.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH)));
                }
            }
        }

        if on_leaf_path {
            // Clone all the sibling hashes now that we know we need to provide
            // them as aux hashes.
            // FIXME: This is definitely wrong.
            let cloned_hashes = sibling_hashes
                .into_iter()
                .map(|sibling_hash| (sibling_hash).map(|hash| hash.clone()))
                .collect();
            auxiliary_hashes.push(cloned_hashes);
            FindSiblingsOutcome::LeafFound(auxiliary_hashes)
        } else {
            FindSiblingsOutcome::NotFound
        }
    }
/// Find siblings of all nodes along the path to the leaf label node.
/// This recursively attempts to find a leaf node with `label` and returns
/// all hashes of sibling nodes from left to right, bottom to top, with
/// None indicating the index of the node that is on the path to the leaf
/// (or the leaf itself).
Find siblings of all nodes along the path to the leaf label node.
This recursively attempts to find a leaf node with `label` and returns
all hashes of sibling nodes from left to right, bottom to top, with
None indicating the index of the node that is on the path to the leaf
(or the leaf itself).
Find siblings of all nodes along the path to the leaf label node . This recursively attempts to find a leaf node with ` label ` and returns all hashes of sibling nodes from left to right bottom to top with None indicating the index of the node that is on the path to the leaf ( or the leaf itself ) .
fn find_siblings(&self, label: &Label) -> FindSiblingsOutcome {
        if self.label == *label {
            if self.is_leaf() {
                return FindSiblingsOutcome::LeafFound(vec![]);
            } else {
                // Node labels should be unique so if we found a non-leaf node
                // of the same label, we short-circuit.
                return FindSiblingsOutcome::NonLeafNodeFound;
            }
        }
        let mut on_leaf_path = false;
        let mut sibling_hashes = vec![];
        let mut auxiliary_hashes = vec![];
        for child in self.children.iter() {
            // If we already found the leaf on this path, we still need to
            // gather siblings at this level but we don't need to recurse into
            // the children.
            if on_leaf_path {
                sibling_hashes.push(Some(child.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH)));
                continue;
            }
            match child.find_siblings(label) {
                FindSiblingsOutcome::NonLeafNodeFound => {
                    // Short circuit.
                    return FindSiblingsOutcome::NonLeafNodeFound;
                }
                FindSiblingsOutcome::LeafFound(child_aux_hashes) => {
                    // Mark that we found the leaf on this path so we should
                    // return siblings.
                    on_leaf_path = true;
                    auxiliary_hashes = child_aux_hashes;
                    // Insert a placeholder empty vector to mark where in the
                    // left -> right flow the path to the leaf was found.
                    sibling_hashes.push(None);
                }
                FindSiblingsOutcome::NotFound => {
                    // Continue to check other branches, but store all children
                    // at this level by reference, in case this is on the path
                    // to the leaf.
                    sibling_hashes.push(Some(child.hash.as_ref().unwrap_or(DEFAULT_EMPTY_HASH)));
                }
            }
        }
        if on_leaf_path {
            // Clone all the sibling hashes now that we know we need to provide
            // them as aux hashes.
            // FIXME: This is definitely wrong.
            let cloned_hashes = sibling_hashes
                .into_iter()
                .map(|sibling_hash| (sibling_hash).map(|hash| hash.clone()))
                .collect();
            auxiliary_hashes.push(cloned_hashes);
            FindSiblingsOutcome::LeafFound(auxiliary_hashes)
        } else {
            FindSiblingsOutcome::NotFound
        }
    }
fn find_siblings ( & self , label : & Label ) -> FindSiblingsOutcome { if self . label == * label { if self . is_leaf ( ) { return FindSiblingsOutcome :: LeafFound ( vec ! [ ] ) ; } else { // Node labels should be unique so if we found a non-leaf node // of the same label, we short-circuit. return FindSiblingsOutcome :: NonLeafNodeFound ; } } let mut on_leaf_path = false ; let mut sibling_hashes = vec ! [ ] ; let mut auxiliary_hashes = vec ! [ ] ; for child in self . children . iter ( ) { // If we already found the leaf on this path, we still need to // gather siblings at this level but we don't need to recurse into // the children. if on_leaf_path { sibling_hashes . push ( Some ( child . hash . as_ref ( ) . unwrap_or ( DEFAULT_EMPTY_HASH ) ) ) ; continue ; } match child . find_siblings ( label ) { FindSiblingsOutcome :: NonLeafNodeFound => { // Short circuit. return FindSiblingsOutcome :: NonLeafNodeFound ; } FindSiblingsOutcome :: LeafFound ( child_aux_hashes ) => { // Mark that we found the leaf on this path so we should // return siblings. on_leaf_path = true ; auxiliary_hashes = child_aux_hashes ; // Insert a placeholder empty vector to mark where in the // left -> right flow the path to the leaf was found. sibling_hashes . push ( None ) ; } FindSiblingsOutcome :: NotFound => { // Continue to check other branches, but store all children // at this level by reference, in case this is on the path // to the leaf. sibling_hashes . push ( Some ( child . hash . as_ref ( ) . unwrap_or ( DEFAULT_EMPTY_HASH ) ) ) ; } } } if on_leaf_path { // Clone all the sibling hashes now that we know we need to provide // them as aux hashes. // FIXME: This is definitely wrong. let cloned_hashes = sibling_hashes . into_iter ( ) . map ( | sibling_hash | ( sibling_hash ) . map ( | hash | hash . clone ( ) ) ) . collect ( ) ; auxiliary_hashes . push ( cloned_hashes ) ; FindSiblingsOutcome :: LeafFound ( auxiliary_hashes ) } else { FindSiblingsOutcome :: NotFound } }
Find siblings of all nodes along the path to the leaf label node.
Find siblings of all nodes along the path to the leaf label node .
&self
label
&Label
&self
label
&Label