mutable reference
A reference that lets you change the value it points to.
A mutable reference &mut T allows changing the referent; only one may exist at a time.
Loading interactive…
Examples
fn add_point(score: &mut u32) { *score += 1; }called asadd_point(&mut score)changesmain's own variable.Two
&mut xborrows in use at the same time are rejected with E0499.
See also