liveBook · Manning

Borrowing

Borrowing is Rust’s mechanism for accessing a value through a reference without transferring ownership, subject to rules governing reference validity and aliasing.

How 3 Manning books explain it

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.

Read how Refactoring to Rust explains borrowing →

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

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.