Mutable reference
A mutable reference is a reference or handle through which the referenced value or storage location may be modified, subject to language-specific access rules.
Learn Rust in a Month of Lunches
A mutable reference is a Rust reference that permits modification of its referent and must be the sole active reference to that referent.
- How it is used
- Uses mutable references to change values directly and through functions without transferring ownership.
- How deep it goes
- Works through `&mut`, dereferencing, reference rules, and compiler feedback, including when a mutable borrow ends after its last use.
- Examples
- Shows numeric updates, a shared-presentation analogy, a compiler borrow error and correction, and a function that appends to a string.
- What you can do after
- Build it from scratch with `&mut`, dereference it to update a value, and pass it to a function without moving ownership.
Read how Learn Rust in a Month of Lunches explains mutable reference →
Refactoring to Rust
A mutable reference is a Rust non-owning reference that permits modification of the referenced value under Rust's aliasing rules.
- How it is used
- Uses mutable references to update borrowed values while preserving ownership and making mutation visible in function signatures.
- How deep it goes
- Explains syntax, ownership-preserving borrowing, aliasing rules, and scope-based validity through an incremental artwork example.
- Examples
- Demonstrates repeated artwork viewing and an incrementing view counter implemented with borrowed references.
- What you can do after
- Apply mutable references to write functions that modify borrowed structs while respecting Rust’s exclusive-aliasing rules.
Code Like a Pro in Rust
A mutable reference is a reference through which the referenced value may be modified.
- How it is used
- Uses exclusive borrowing to modify existing data safely and support in-place operations.
- How deep it goes
- Explains borrow-checker exclusivity and signature-based copy detection, but defers detailed underlying algorithms.
- Examples
- Uses make_ascii_lowercase for in-place mutation and contrasts it with to_lowercase returning a copied String.
- What you can do after
- Apply &mut parameters to implement in-place mutation and diagnose likely copying from function signatures.
Read how Code Like a Pro in Rust explains mutable reference →
Related concepts
- referencecontrasts with · An immutable Rust reference is a non-owning borrow that provides read-only access to a value without taking ownership of it.
- immutable collectioncontrasts with · An immutable collection is a collection whose membership and contents cannot be changed after creation.
- self parametercontrasts with · A self parameter is a method receiver representing the instance or object on which the method operates or is invoked.
- referencekind of · A reference is an indirect value or relationship that identifies or provides access to another value, object, resource, or source.
- interior mutabilitycontrasts with · Interior mutability is a programming mechanism that permits mutation through an otherwise shared or immutable access path while enforcing safety through specialized checks or synchronization.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


