Borrowing
Borrowing is Rust’s mechanism for accessing a value through a reference without transferring ownership, subject to rules governing reference validity and aliasing.
Refactoring to Rust
Rust's borrowing rules constrain the number, mutability, and validity of references to a value.
- How it is used
- Lets functions use a value repeatedly without taking ownership, including when reading an NGINX request through a reference.
- How deep it goes
- Defines reference-count, mutability, and validity rules, then applies them to a moved-value error and an unsafe pointer conversion.
- Examples
- Uses repeated artwork viewing and an NGINX request-body handler to show ordinary borrowing and checked pointer conversion.
- What you can do after
- Practice/perform it by passing artwork by reference and checking pointer validity before borrowing an NGINX request.
Rust Servers, Services, and Apps
Borrowing is Rust's mechanism for granting temporary access to a value without transferring its ownership.
- How it is used
- Uses borrowing to provide temporary value access while preserving Rust’s explicit ownership model.
- 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 you can do after
- Evaluate/understand how Rust permits temporary access without ownership transfer or invalid memory access.
Read how Rust Servers, Services, and Apps explains borrowing →
Rust in Action: Systems programming concepts and techniques
Borrowing is Rust's mechanism for temporarily accessing a value through a reference without taking ownership of it.
- How it is used
- Uses references to give functions access to values without moving ownership, avoiding moved-value errors in a satellite messaging program.
- How deep it goes
- Explains read-only and mutable reference syntax through a worked mailbox program and states the one-read-write-borrow limit.
- Examples
- Contrasts a repeated satellite status call that fails after a move with a mailbox that uses &mut CubeSat to send messages.
- What you can do after
- Diagnose/debug moved-value errors and use read-only or mutable references when a function needs access rather than ownership.
Read how Rust in Action: Systems programming concepts and techniques explains borrowing →
Related concepts
- 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.
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.


