Need Assistance?

support@tutorialshub.in

Borrowing, References & Slices

Mutable References (&mut T) & Borrow Rules

ADVERTISEMENT
Rust Free Lesson
5 min read
ADVERTISEMENT

To let a function modify borrowed data, pass a mutable reference (&mut). Rust enforces one golden rule to prevent data races:

At any given time, you can have EITHER one mutable reference (&mut T) OR any number of immutable references (&T)—never both at the same time!

ADVERTISEMENT
Hi, I'm Tuby! Here to help you