liveBook · Manning

Refcell

RefCell is a Rust standard-library container that provides interior mutability by checking borrowing rules at runtime.

How 3 Manning books explain it

Idiomatic Rust

RefCell is Rust's single-threaded interior-mutability container that checks borrowing rules at runtime.

How it is used
Enables mutation of owned data inside an immutable container when ordinary mutable access is unavailable.
How deep it goes
Explains runtime-enforced interior mutability and demonstrates borrow_mut(), without detailing borrow-conflict behavior.
Examples
Moves an immutable String into RefCell, calls borrow_mut().push_str(...), and displays the changed value.
What you can do after
Apply it via RefCell::from and borrow_mut() to mutate an owned String without a mutable container binding.

Read how Idiomatic Rust explains refcell →

Code Like a Pro in Rust

RefCell is a Rust standard-library type that provides runtime-checked borrowing and interior mutability for single-threaded code.

How it is used
Enables mutable access inside shared, single-threaded data structures when ordinary mutable references are too restrictive.
How deep it goes
Explains when to use RefCell and shows its placement in a list; defers concurrency and does not detail runtime borrow checks.
Examples
Uses a doubly linked list whose node references have the type `Rc<RefCell<ListItem<T>>>`.
What you can do after
Apply it via Rust’s `RefCell` and `Rc` to structure mutable, shared nodes in a single-threaded list.

Read how Code Like a Pro in Rust explains refcell →

Learn Rust in a Month of Lunches

RefCell is a Rust standard-library container that enforces borrowing rules at run time and permits mutation through an immutable access path.

How it is used
Enables selected fields to change through immutable access paths when ordinary mutable references are inconvenient.
How deep it goes
Explains initialization, borrowing methods, runtime panics, error-returning alternatives, and thread restrictions.
Examples
Uses a User with an active RefCell<bool>, direct mutation, double mutable borrowing, and the resulting panic.
What you can do after
Apply it via RefCell::new, borrow, borrow_mut, and try_borrow_mut while avoiding invalid simultaneous borrows.

Read how Learn Rust in a Month of Lunches explains refcell →

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.