Unlike C++ references, Rust references do not propagate mutability. It behaves like a C pointer in this regard. This should not be confused as interior mutability.
For example, in the following code, we can mutate what mref
refers to even though mref
itself is not mut
.
fn main() {
let mut i = 0;
println!("{i}");
let mref = &mut i;
*mref += 1;
println!("{i}");
}