&T
has interior mutability: depending on the nature of type T
, it is allowed to change the referenced data, and you cannot assume that the value of &T
doesn’t change. For example, if you have &AtomicUsize
, then you can change the value of it by fn AtomicUsize::store()
.
Will it be useful to support another reference type, &immut T
, which doesn’t allow any modification to the referenced data? Right now I can see one benefit: &immut T
will admit more compiler optimizations than &T
.