value.lock().unwrap()returns a value of the type MutexGuardthat the implementation has DerefMut:
impl<'mutex, T: ?Sized> DerefMut for MutexGuard<'mutex, T> {
fn deref_mut(&mut self) -> &mut T { ... }
}
DerefMut::deref_mut(x)equivalently &mut *x; Naturally, it is DerefMutalso used for appointments under the pointer, as in your case.
Therefore, for the *v += 1operation vto be a variable mut- otherwise it would be impossible to call DerefMut::deref_mutat all.
*value.lock().unwrap() += 1 , value.lock().unwrap() , Rust .
, Mutex UnsafeCell, DerefMut; , Mutex -, , .. . .