9.7 Reborrowing: The Automatic Coercion from &mut to &
Alright, let’s talk about one of Rust’s more subtle party tricks: reborrowing. You’ve probably already experienced this without even realizing it, which is a testament to how well the compiler engineers designed this feature. It’s the reason you don’t have to tear your hair out nearly as often as you might expect when juggling mutable references. Imagine you have a &mut T—your coveted exclusive, mutable reference. You want to call a function that takes a &T, an immutable reference. In a strictly literal world, this shouldn’t work. You have an exclusive mutable ticket, and the function just wants a shared, read-only ticket. They’re different types! But try it: