struct C {
p: String,
q: String,
}
impl C {
fn call(&mut self) {}
}
fn main(){
let mut c = C { p: "p".to_string(), q: "q".to_string() };
let p = &mut c.p; // first mutable borrow occurs here
let q = &mut c.q; // second mutable borrow doesn't occur here, why???
c.call(); // second mutable borrow occurs here // error[E0499]: cannot borrow `c` as mutable more than once at a time
p.push('x');
q.push('y');
}
let q = &mut c.q;
second mutable borrow doesn't occur here, why??? I really can't figure it out, can someone explain why in depth?