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
You don't want into_inner() nor try_unwrap(). As evident from their name and documentation, they consume the wrapper (the RefCell and the Rc, respectively), returning the wrapped value by-value.
If you need a mutable reference to the inner value, use RefCell::borrow_mut() instead. That's the whole point of using a RefCell.