I need help understanding this error. How do I get a mutable reference to the TreeNode in root? Root is defined as:
// Definition for a binary tree node.
// #[derive(Debug, PartialEq, Eq)]
// pub struct TreeNode {
// pub val: i32,
// pub left: Option<Rc<RefCell<TreeNode>>>,
// pub right: Option<Rc<RefCell<TreeNode>>>,
// }
//
// impl TreeNode {
// #[inline]
// pub fn new(val: i32) -> Self {
// TreeNode {
// val,
// left: None,
// right: None
// }
// }
// }
Thanks!
Line 41, Char 26: borrow of moved value: `rootTreeNode` (solution.rs)
|
26 | let mut rootTreeNode = Rc::try_unwrap(root.unwrap()).unwrap().into_inner(); // I've borrowed the RefCell instance
| ---------------- move occurs because `rootTreeNode` has type `tree_node::TreeNode`, which does not implement the `Copy` trait