mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
Update 二叉树理论基础.md
This commit is contained in:
@ -275,15 +275,15 @@ rust:
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct TreeNode {
|
pub struct TreeNode<T> {
|
||||||
pub val: i32,
|
pub val: T,
|
||||||
pub left: Option<Rc<RefCell<TreeNode>>>,
|
pub left: Option<Rc<RefCell<TreeNode<T>>>>,
|
||||||
pub right: Option<Rc<RefCell<TreeNode>>>,
|
pub right: Option<Rc<RefCell<TreeNode<T>>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TreeNode {
|
impl<T> TreeNode<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new(val: i32) -> Self {
|
pub fn new(val: T) -> Self {
|
||||||
TreeNode {
|
TreeNode {
|
||||||
val,
|
val,
|
||||||
left: None,
|
left: None,
|
||||||
|
Reference in New Issue
Block a user