Trait monster::incubation::map_ref_mut::MapRefMutExt [] [src]

pub trait MapRefMutExt: Sized {
    unsafe fn map_ref_mut<F>(&mut self, f: F)
    where
        F: FnOnce(Self) -> Self
, { ... } }

Provided Methods

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::MapRefMutExt;

let mut foo = &mut 123;

unsafe { foo.map_ref_mut(|n| n + 654) }

assert_eq!(*foo, 777);

Implementors