Function monster::incubation::map_ref_mut::map_ref_mut
[−]
[src]
pub unsafe fn map_ref_mut<T, F>(thing: &mut T, f: F) where
F: FnOnce(T) -> T,
Map the value of a mutable reference.
Useful if you want to apply a FnOnce(T) -> T
to a &mut T
.
This function is unsafe because panicking in f
would leave the pointee uninitialized.
Example
use monster::incubation::map_ref_mut; let foo = &mut 123; unsafe { map_ref_mut(foo, |n| n + 654) } assert_eq!(*foo, 777);