Borrowing is Rust's mechanism for granting temporary access to a value without transferring its ownership.
Borrowing grants temporary access to a value without transferring ownership. Rust uses references and compile-time checking to keep borrowed access within the value’s lifetime. section 1.2.2
Borrowing uses two reference forms with exclusive mutation rules:
Use `&` to create a reference to a value. section 1.2.2
Use `&T` for immutable sharing without mutation. section 1.2.2
Use `&mut T` for mutation, excluding all other mutable or immutable borrows of that object. section 1.2.2
The borrow checker ensures references do not outlive the values they borrow, preventing invalid memory access at compile time. section 1.2.2
How Rust Servers, Services, and Apps covers it
How deep it goes
Defines immutable and mutable references and compiler rules, but does not develop implementation examples or lifetime syntax.
Examples
Uses `&T` for shared access and `&mut T` for exclusive mutation.
What it assumes
Assumes ownership concepts while teaching references, temporary access, and mutable-borrow exclusivity.
What you can do after
Evaluate/understand how Rust permits temporary access without ownership transfer or invalid memory access.
How it connects
Connects borrowing to ownership, references, the borrow checker, lifetimes, memory safety, and thread safety.
referenceproduces · A reference is an indirect value or relationship that identifies or provides access to another value, object, resource, or source.
borrow checkerused by · A borrow checker is a compile-time mechanism that verifies ownership, borrowing, and reference rules to prevent invalid memory access.
ownershipalternative to · Ownership is a programming-language model that assigns responsibility for controlling a value or resource, including its lifetime and eventual cleanup.
Rustpart of · Rust is a statically typed systems programming language designed for performance, concurrency, and memory safety without requiring garbage collection.
mutable referenceimplemented by · 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.
This explainer was generated by Manning's knowledge graph from the text of Rust Servers, Services, and Apps. The section links point to the parts of the book it draws on.