Closed DianaNites closed 3 years ago
The map_mut
method is for &mut
references (e.g. Volatile<&mut u32>
) and gives full access to the wrapped value. The map
method, in constrast, only requires a shared &
reference (e.g. Volatile<&u32>
), but does not allow modification of the wrapped value.
(I'm not sure if I understood your question right, so please let me know if anything is still unclear.)
I was browsing the documentation and noticed that
map
takesF: FnOnce(&'a T) -> &'a U
andT: 'a
, butmap_mut
takesF: FnOnce(&mut T) -> &mut U
andT: 'a
and wondered about the difference?