/// Traverses the network of nodes and returns the input node
fn get_input(node: Rc<RefCell<Box<Node>>>) -> Rc<RefCell<Box<Node>>> {
match **node.borrow() { // here
Node::Input { .. } => Rc::clone(&node),
_ => { ... },
}
}
I'm confused as to why this edit was suggested and why it works. What I think is most confusing are the implicit dereferences that sometimes happen.
For example, .borrow()
is a method of RefCell
, yet I'm allowed to call it directly on an Rc
. Moreover this works too: **(*node).borrow()
.