r2
is a reborrow of r1
. you can use r1
again after the last use of r2
.
for example, this is OK:
let mut a: i32 = 0;
let r1 = &mut a;
let r2: &mut i32 = r1;
println!("{}", r2);
println!("{}", r1);
but this is NOT:
let mut a: i32 = 0;
let r1 = &mut a;
let r2: &mut i32 = r1;
println!("{}", r1);
println!("{}", r2);
see also this recent thread: