In Rust, interior mutability refers to cell type wrappers, such as Cell and RefCell, which allow you to make data mutable, without needing to pass mutable references around.
In Rust, interior mutability refers to cell type wrappers, such as Cell
and RefCell
, which allow you to make data mutable, without needing to pass mutable references around.
Interior mutability provides an escape hatch for when it would be inconvenient or impossible to make use of mutable references. While access to mutable references is checked at compile-time, controlling access to data wrapped in a cell is deferred until runtime.