liveBook · Manning

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.

How 3 Manning books explain it

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.

Read how Refactoring to Rust explains mutable reference →

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

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.