&mut are more about shared/exclusive access rather than mutability per se.
In Rust, mutable references never alias. Breaking this rule in any way results in undefined behavior.
On the other hand, many types have “interior mutability”—they can be mutated even through const references.
&mut as shared/exclusive access (rather than constant/mutable) is most important when dealing with Sync types.
std::cell::UnsafeCell allows you to opt out of
&immutability, but not
Note that only the immutability guarantee for shared references is affected by
UnsafeCell. The uniqueness guarantee for mutable references is unaffected. There is no legal way to obtain aliasing
&mut, not even with