I was playing around with creating references and I ended up having this:
let mut z: &mut i32 = &mut 42;
but also the following that compiles
let &mut z: &mut i32 = &mut 42;
I was not actually aware that I could have the let &mut z form, as must of the occurrences I have seen has always been let mut z: which I interpret to mean, make it possible for z, to hand out mutable reference.
And it's somewhat tangential, but I'll mention that while &mut T is a distinct type compared to T or &T, the mut marker in a binding (let mut z = ...) doesn't change the type, it just changes whether or not you can overwrite or create a mutable reference to the variable.
It's an aid to avoid mutating things you don't mean to, but you could always assign the value to a new variable with a mutable binding, so adding or not adding mut doesn't change anything inherent to the type or value. It's just a property of the binding.
For example you can do:
let z = 13;
let mut z = z;
z = 42;
let z = z;
Variable declarations are patterns, not just names with an optional mut marker. In this case, the &mut in let &mut z "unwraps" the &mut of the type and of the value on the right:
When are variable declarations patterns? Like in the case of let &mut z: and when are they not patterns? As in the case let mut z, where the mut is just a mutable binding marker, and doesn't "unwrap" anything