遍历,使用了 unwrap,使用 match 也可
(&self)
| 53 | |
| 54 | // 遍历,使用了 unwrap,使用 match 也可 |
| 55 | fn preorder(&self) { |
| 56 | println!("key:{:?}, value:{:?}", &self.key, &self.val); |
| 57 | if !self.left.is_none() { self.left.as_ref().unwrap().preorder(); } |
| 58 | if !self.right.is_none() { self.right.as_ref().unwrap().preorder(); } |
| 59 | } |
| 60 | |
| 61 | // 遍历,使用了 match,使用 unwarp 也可 |
| 62 | fn inorder(&self) { |