rust-osdev/volatile

Volatile::map and Volatile::map_mut use slightly different `F` bounds?

Closed this issue · 1 comments

I was browsing the documentation and noticed that map takes F: FnOnce(&'a T) -> &'a U and T: 'a, but map_mut takes F: FnOnce(&mut T) -> &mut U and T: 'a and wondered about the difference?

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.)