Interior mutability
Sometimes you need to change something you only hold a shared reference to. Cell and RefCell
allow that by moving the borrow check from compile time to run time — which means the panic is now
your problem.
Short chapter, specific problems. If you never share mutable state through a reference, skip it.
Articles
Section titled “Articles”Nothing published in this chapter yet — all 6 articles are still to come.
Coming up (6)
- What is RefCell and interior mutability?a borrow check that happens at runtime
- What is the difference between Cell and RefCell?copy in and out, versus borrow
- What is the difference between Rc and RefCell?sharing versus mutating
- How to fix “already borrowed: BorrowMutError”find the borrow that did not end
- When should you use interior mutability?the four cases where it is the answer
- How to mutate through a shared referencethe pattern that looks illegal and is not