Skip to content

Commit 1c43d21

Browse files
committed
refactor: change the return type of BinarySearchTree::get_root to reference
1 parent 3fc811c commit 1c43d21

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

codes/rust/chapter_tree/binary_search_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ impl BinarySearchTree {
2525
}
2626

2727
/* 获取二叉树根节点 */
28-
pub fn get_root(&self) -> Option<Rc<RefCell<TreeNode>>> {
29-
self.root.clone()
28+
pub fn get_root(&self) -> &Option<Rc<RefCell<TreeNode>>> {
29+
&self.root
3030
}
3131

3232
/* 查找节点 */

0 commit comments

Comments
 (0)