Interior Mutability
Cell, RefCell, and Mutex allow mutation through a shared reference by moving the aliasing-XOR-mutability check from compile time to runtime: Cell swaps whole values, RefCell panics on conflicting borrows, and Mutex blocks. Use it when the borrow checker cannot see that access is actually exclusive, such as shared state behind Rc or Arc.
This Concept is waiting for its first lesson!
Cell, RefCell, and Mutex allow mutation through a shared reference by moving the aliasing-XOR-mutability check from compile time to runtime: Cell swaps whole values, RefCell panics on conflicting borrows, and Mutex blocks. Use it when the borrow checker cannot see that access is actually exclusive, such as shared state behind Rc or Arc.
Are you a teacher? Sign in to start contributing.
Sign In