Mutable References

Overview

A mutable reference (&mut T) allows mutation through a borrow, but Rust enforces exclusivity: at a given time, either one mutable reference or any number of immutable references.

These rules prevent data races and aliasing bugs at compile time.

Official Rust Book: Mutable References


Code example