std::borrow::BorrowMut - Rust
Description: API documentation for the Rust `BorrowMut` trait in crate `std`.
Keywords: rust, rustlang, rust-lang, BorrowMut

# Trait std::borrow::BorrowMut 1.0.0 [−] [src]

    pub trait BorrowMut<Borrowed>: Borrow<Borrowed> where
        Borrowed: ?Sized, {
        fn borrow_mut(&mut self) -> &mut Borrowed;
    }

A trait for mutably borrowing data.

Similar to `Borrow`, but for mutable borrows.

## Required Methods

### `fn borrow_mut(&mut self) -> &mut Borrowed`

Mutably borrows from an owned value.

# Examples

    use std::borrow::BorrowMut;

    fn check<T: BorrowMut<[i32]>>(mut v: T) {
        assert_eq!(&mut [1, 2, 3], v.borrow_mut());
    }

    let v = vec![1, 2, 3];

    check(v);Run

## Implementors

- `impl<T> BorrowMut<T> for Box<T> where
  T: ?Sized,`
- `impl<T> BorrowMut<[T]> for Vec<T>`
- `impl<T> BorrowMut<[T]> for [T; 5]`
- `impl<T> BorrowMut<[T]> for [T; 7]`
- `impl<T> BorrowMut<[T]> for [T; 4]`
- `impl<T> BorrowMut<[T]> for [T; 20]`
- `impl<T> BorrowMut<[T]> for [T; 27]`
- `impl<T> BorrowMut<[T]> for [T; 8]`
- `impl<T> BorrowMut<[T]> for [T; 3]`
- `impl<T> BorrowMut<[T]> for [T; 26]`
- `impl<T> BorrowMut<[T]> for [T; 18]`
- `impl<T> BorrowMut<[T]> for [T; 24]`
- `impl<T> BorrowMut<[T]> for [T; 1]`
- `impl<T> BorrowMut<[T]> for [T; 25]`
- `impl<T> BorrowMut<[T]> for [T; 15]`
- `impl<T> BorrowMut<[T]> for [T; 16]`
- `impl<T> BorrowMut<[T]> for [T; 0]`
- `impl<T> BorrowMut<[T]> for [T; 11]`
- `impl<T> BorrowMut<[T]> for [T; 2]`
- `impl<T> BorrowMut<[T]> for [T; 22]`
- `impl<T> BorrowMut<[T]> for [T; 28]`
- `impl<T> BorrowMut<[T]> for [T; 23]`
- `impl<T> BorrowMut<[T]> for [T; 17]`
- `impl<T> BorrowMut<[T]> for [T; 13]`
- `impl<T> BorrowMut<[T]> for [T; 14]`
- `impl<T> BorrowMut<[T]> for [T; 31]`
- `impl<T> BorrowMut<[T]> for [T; 30]`
- `impl<T> BorrowMut<[T]> for [T; 29]`
- `impl<T> BorrowMut<[T]> for [T; 21]`
- `impl<T> BorrowMut<[T]> for [T; 9]`
- `impl<T> BorrowMut<[T]> for [T; 6]`
- `impl<T> BorrowMut<[T]> for [T; 12]`
- `impl<T> BorrowMut<[T]> for [T; 10]`
- `impl<'a, T> BorrowMut<T> for &'a mut T where
  T: ?Sized,`
- `impl<T> BorrowMut<[T]> for [T; 19]`
- `impl<T> BorrowMut<T> for T where
  T: ?Sized,`
- `impl<T> BorrowMut<[T]> for [T; 32]`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)