Reborrow vs move

{node} is not moving the thing node points to, it's moving the pointer itself. &mut T pointers are non-copyable, meaning they can only be moved or re-borrowed.

If Rust didn't do automatic re-borrowing, then any time you did func(some_mut_borrow), then some_mut_borrow would be unusable after the function call. That would be a huge pain in the backside, so the compiler inserts the rough equivalent of func(&mut *some_mut_borrow) for you.

8 Likes