Merge pull request #1734 from Jack-Zhang-1314/patch-6

update 二叉树理论基础.md about rust
This commit is contained in:
程序员Carl
2022-11-16 10:11:05 +08:00
committed by GitHub

View File

@ -270,6 +270,29 @@ class TreeNode(_value: Int = 0, _left: TreeNode = null, _right: TreeNode = null)
var right: TreeNode = _right
}
```
rust:
```rust
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode<T> {
pub val: T,
pub left: Option<Rc<RefCell<TreeNode<T>>>>,
pub right: Option<Rc<RefCell<TreeNode<T>>>>,
}
impl<T> TreeNode<T> {
#[inline]
pub fn new(val: T) -> Self {
TreeNode {
val,
left: None,
right: None,
}
}
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>