I am learning rust recently and encountered a concept problem.
fn main() {
let mut a = String::from("hello");
let b = &mut a;
println!("{}", b);
println!("{}", a);
}
here, b
is a mutable reference of a. But I can't change the mutable variable a
anymore until the lifetime of b is over.
so What's the difference between
let b = &a
and let b = &mut a;
Because both a
and b
are not mutable.