Mutable reference
A mutable reference is a reference or handle that provides access to a value or storage location that can be modified, subject to the language’s 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 borrowed values without transferring ownership, including across function calls.
- How deep it goes
- Explains syntax, dereferencing, exclusivity, borrow end points, and compiler feedback through worked examples.
- Examples
- Uses a numeric update, a presentation-editing analogy, a conflicting borrow, and a function that appends to a country string.
- What you can do after
- Apply mutable borrowing to update values and function arguments while resolving overlapping-reference errors.
Read how Learn Rust in a Month of Lunches explains mutable reference →
Data-Oriented Programming in Java
A mutable reference is a reference that provides access to an object whose state can be changed.
- How it is used
- Exposes how shared mutable state undermines records, value objects, encapsulation, and invariant enforcement.
- How deep it goes
- Demonstrates externally visible mutation, hash-collection consequences, defensive copying, immutable wrappers, and encapsulation failures.
- Examples
- Uses mutable Date and List fields, Person records, HashSet behavior, Cart entities, defensive copies, and immutable collection wrappers.
- What you can do after
- Diagnose shared-state hazards and apply defensive copying or immutable collection types at construction boundaries.
Read how Data-Oriented Programming in Java 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 →
Rust Web Development
A Rust reference that permits mutation of the value it refers to, subject to Rust’s borrowing rules.
- How it is used
- Uses mutable references to modify a String in a function and update a question in a REST API handler.
- How deep it goes
- Explains mutation through a function parameter and HashMap lookup, without detailing borrowing-rule constraints.
- Examples
- Uses a String address extended with a postal code and a HashMap question replaced by ID.
- What you can do after
- Apply mutable references in Rust to modify a String through a function or update a question obtained from a HashMap.
Also covered in
- Rust in Action: Systems programming concepts and techniques
- Functional Programming in Scala, Second Edition
- React in Depth
- Embedded Software with RustIn early access (MEAP)
What to know first
- stringA string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
- garbage collectionGarbage collection is an automated process that identifies and reclaims or removes memory, data, or other items no longer reachable or needed by a system.
Related concepts
- referencecontrasts with · An immutable Rust reference is a non-owning borrowed pointer-like value that provides read-only access to a value without taking ownership of it.
- immutable collectioncontrasts with · An immutable collection is a collection whose contents cannot be changed after it is created.
- self parametercontrasts with · A self parameter is a method receiver representing the instance or object on which the method operates or is invoked.
- stringuses · A string is a programming-language value representing textual data as an ordered sequence of characters or encoded units.
- referencekind of · A reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
Questions about mutable reference
What is mutable reference?
A mutable reference is a reference or handle that provides access to a value or storage location that can be modified, subject to the language’s access rules.
Which Manning books explain mutable reference?
Learn Rust in a Month of Lunches, Data-Oriented Programming in Java, Refactoring to Rust, Code Like a Pro in Rust and Rust Web Development.
What should I know before learning mutable reference?
Manning books that teach mutable reference usually introduce string and garbage collection first.
What is the difference between mutable reference and reference?
A mutable reference is a reference or handle that provides access to a value or storage location that can be modified, subject to the language’s access rules. An immutable Rust reference is a non-owning borrowed pointer-like value that provides read-only access to a value without taking ownership of it.
What is mutable reference a kind of?
Mutable reference is a kind of reference. A reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
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.




