O'Reilly logo
  • Ivan Zderadicka thinks this is interesting:

We could make append take a mutable reference to self, but that would mean that we could only append to the list if all the nodes' bindings were mutable, forcing the whole structure to be mutable.


Cover of Mastering Rust


This explanation is confusing - first in the code above append already uses &mut self. But key problem is that even if we can have mutable reference to node here, it will not help as node is Rc, which is smart pointer that does not implement DerefMut - so we can never get mutable reference to struct it contain and this can never modify its field!