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.

This trait is similar to AsRef but used for converting between mutable references.

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

Generic Implementations

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

Required Methods

Important traits for &'a mut I

Performs the conversion.

Implementors