feat: add rust docs (#815)

* feat: add rust docs

* Import std types for built_in_hash doc
This commit is contained in:
易春风
2023-10-01 19:25:03 +08:00
committed by GitHub
parent e8bf5879b0
commit cbe76b58a2
8 changed files with 162 additions and 12 deletions
+21
View File
@@ -153,7 +153,28 @@ AVL 树既是二叉搜索树也是平衡二叉树,同时满足这两类二叉
=== "Rust"
```rust title=""
use std::rc::Rc;
use std::cell::RefCell;
/* AVL 树节点类型 */
struct TreeNode {
val: i32, // 节点值
height: i32, // 节点高度
left: Option<Rc<RefCell<TreeNode>>>, // 左子节点
right: Option<Rc<RefCell<TreeNode>>>, // 右子节点
}
impl TreeNode {
/* AVL 树节点构造方法 */
fn new(val: i32) -> Rc<RefCell<Self>> {
Rc::new(RefCell::new(Self {
val,
height: 0,
left: None,
right: None
}))
}
}
```
=== "C"