Crates.io | common-tree |
lib.rs | common-tree |
version | 0.2.0 |
source | src |
created_at | 2021-09-09 04:17:56.469389 |
updated_at | 2021-09-12 03:46:26.883871 |
description | common tree lib |
homepage | https://github.com/chanble/common-tree |
repository | https://github.com/chanble/common-tree |
max_upload_size | |
id | 448710 |
size | 12,411 |
通用树结构库, 是现实了深度遍历(preorder, 先序遍历)和广度优先遍历
更多可以查看examples
use common_tree::Node;
struct NodeData {
id: usize,
name: String,
}
impl NodeData {
pub fn new(id: usize, name: String) -> Self {
Self {
id,
name,
}
}
pub fn print(&self) {
println!("id: {}, name: {}", self.id, self.name);
}
}
type HellNode = Node<NodeData>;
fn main() {
let root = HellNode::new(NodeData::new(0, format!("root")));
root.data().print();
}
cargo run --example hello