// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // Copyright by contributors to this project. // SPDX-License-Identifier: (Apache-2.0 OR MIT)
use alloc::string::String; use alloc::{format, vec}; use core::borrow::BorrowMut;
if nodes.total_leaf_count().root() == idx {
parent_tag = format!("{blank_tag}Root ({idx})");
}
// Add unmerged leaves indexes let unmerged_leaves_idxs = match nodes.borrow_as_parent(idx) {
Ok(parent) => parent
.unmerged_leaves
.iter()
.map(|leaf_idx| format!("{}", leaf_idx.0))
.collect(),
Err(_) => { // Empty parent nodes throw `NotParent` error when borrow as Parent
vec![]
}
};
if !unmerged_leaves_idxs.is_empty() { let unmerged_leaves_tag =
format!(" unmerged leaves idxs: {}", unmerged_leaves_idxs.join(","));
parent_tag.push_str(&unmerged_leaves_tag);
}
letmut branch = tree.add_branch(&parent_tag);
//This cannot panic, as we already checked that idx is not a leaf
build_tree(tree, nodes, idx.left_unchecked())?;
build_tree(tree, nodes, idx.right_unchecked())?;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.