W3cubDocs

/Rust

Trait std::borrow::BorrowMut

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

A trait for mutably borrowing data.

As a companion to Borrow<T> this trait allows a type to borrow as an underlying type by providing a mutable reference. See Borrow<T> for more information on borrowing as another type.

Required methods

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

ⓘImportant traits for &'_ mut F
impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized, 
    type Output = <F as Future>::Output;
impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized, 
    type Item = <I as Iterator>::Item;
impl<'_, R: Read + ?Sized> Read for &'_ mut R
impl<'_, W: Write + ?Sized> Write for &'_ mut W

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);
Loading content...

Implementors

impl BorrowMut<str> for String[src]

impl<'_, T> BorrowMut<T> for &'_ mut T where
    T: ?Sized
[src]

ⓘImportant traits for &'_ mut F
impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized, 
    type Output = <F as Future>::Output;
impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized, 
    type Item = <I as Iterator>::Item;
impl<'_, R: Read + ?Sized> Read for &'_ mut R
impl<'_, W: Write + ?Sized> Write for &'_ mut W

impl<T> BorrowMut<[T]> for [T; 0][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 1][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 2][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 3][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 4][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 5][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 6][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 7][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 8][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 9][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 10][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 11][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 12][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 13][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 14][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 15][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 16][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 17][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 18][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 19][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 20][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 21][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 22][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 23][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 24][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 25][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 26][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 27][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 28][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 29][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 30][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 31][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for [T; 32][src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<[T]> for Vec<T>[src]

ⓘImportant traits for &'_ [u8]
impl<'_> Read for &'_ [u8]
impl<'_> Write for &'_ mut [u8]

impl<T> BorrowMut<T> for Box<T> where
    T: ?Sized
[src]

ⓘImportant traits for &'_ mut F
impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized, 
    type Output = <F as Future>::Output;
impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized, 
    type Item = <I as Iterator>::Item;
impl<'_, R: Read + ?Sized> Read for &'_ mut R
impl<'_, W: Write + ?Sized> Write for &'_ mut W

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

ⓘImportant traits for &'_ mut F
impl<'_, F> Future for &'_ mut F where
    F: Unpin + Future + ?Sized, 
    type Output = <F as Future>::Output;
impl<'_, I> Iterator for &'_ mut I where
    I: Iterator + ?Sized, 
    type Item = <I as Iterator>::Item;
impl<'_, R: Read + ?Sized> Read for &'_ mut R
impl<'_, W: Write + ?Sized> Write for &'_ mut W
Loading content...

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/borrow/trait.BorrowMut.html