This exercice from Rustlings, once corrected, gives:
fn move_semantics4() { let mut x = Vec::new(); let y = &mut x; y.push(42); let z = &mut x; z.push(13); assert_eq!(x, [42, 13]); } If I put it through Aquascope, on the borrow checker, it gives:
I don't understand why x is loosing ownership on L3 and L5. AFAIK, the mutable reference assignated to y and z implies:
- No more reference can be created on
x(only one mutable reference at a time) - Ability for
yandz(sequentially) to read and write on vector
But not loosing ownership.
According to me, visual representation seems validating the ownership staying on x:
Could someone elaborate on this?
EDIT: for the sake of completness, I created another snippet with both move and mutable reference, and there is a special char (fat arrow) when a move is made :



xkeeps being the owner of theVecduring the entire snippet.