Trait std::convert::AsMut1.0.0 [] [src]

pub trait AsMut<T> where T: ?Sized {
    fn as_mut(&mut self) -> &mut T;
}

A cheap, mutable reference-to-mutable reference conversion.

Note: this trait must not fail. If the conversion can fail, use a dedicated method which returns an Option<T> or a Result<T, E>.

Examples

Box<T> implements AsMut<T>:

fn add_one<T: AsMut<u64>>(num: &mut T) {
    *num.as_mut() += 1;
}

let mut boxed_num = Box::new(0);
add_one(&mut boxed_num);
assert_eq!(*boxed_num, 1);Run

Generic Impls

Required Methods

Performs the conversion.

Implementors