Problem with mutable references in Rust
I was trying to make a Linked list in rust. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2c092e247e1c08b8f0dd802657f6b250 The `next` method on mutable iterator for my linked list (named ListIteratorMutable on line 143) has a return type `&'a mut Node<T>`. When I run the code, it gives me an error "cannot move out of `node` because it is borrowed". As far as I understood, it was because of more than 1 mutable references being made (because the immutable ListIterator on line 128 works fine). The weird part was that when I changed the return type from `&'a mut Node<T>` to `&'a mut T` and made the changes necessary to return that type, it worked fine. https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a881ec2bfd259bae9c6bbdbb3cdbfb7b I would love an explanation on what just happened.