Shared and Mutable References
Updated
October 31, 2026
Shared and Mutable References
Instead of transferring ownership, a function can access data via references. This mechanism is called borrowing.
Shared References (&T)
Shared references allow read-only access to data without taking ownership:
Mutable References (&mut T)
Mutable references permit modifying the borrowed value: