TupleMut

Trait TupleMut 

Source
pub trait TupleMut {
    type Mut<'a>
       where Self: 'a;

    // Required method
    fn tuple_mut(&mut self) -> Self::Mut<'_>;
}
Expand description

A trait for tuples that provides a method to get a tuple of mutable references.

This trait provides both an associated type Mut<'a> that represents a tuple of mutable references to the elements, and a method tuple_mut that returns such a tuple.

§Examples

use tuplities_mut::TupleMut;

let mut tuple = (1, "hello".to_string(), vec![1, 2, 3]);
let mut_refs = tuple.tuple_mut();
*mut_refs.0 = 42;
mut_refs.1.push_str(" world");
mut_refs.2.push(4);
assert_eq!(tuple, (42, "hello world".to_string(), vec![1, 2, 3, 4]));

Part of the tuplities crate.

Required Associated Types§

Source

type Mut<'a> where Self: 'a

The type of a tuple containing mutable references to each element.

Required Methods§

Source

fn tuple_mut(&mut self) -> Self::Mut<'_>

Returns a tuple of mutable references to each element.

§Examples
use tuplities_mut::TupleMut;

let mut tuple = (42, "world".to_string());
let mut_refs = tuple.tuple_mut();
*mut_refs.0 = 24;
mut_refs.1.make_ascii_uppercase();
assert_eq!(tuple, (24, "WORLD".to_string()));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TupleMut for ()

Source§

type Mut<'a> = () where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1> TupleMut for (T1,)

Source§

type Mut<'a> = (&'a mut T1,) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2> TupleMut for (T1, T2)

Source§

type Mut<'a> = (&'a mut T1, &'a mut T2) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2, T3> TupleMut for (T1, T2, T3)

Source§

type Mut<'a> = (&'a mut T1, &'a mut T2, &'a mut T3) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2, T3, T4> TupleMut for (T1, T2, T3, T4)

Source§

type Mut<'a> = (&'a mut T1, &'a mut T2, &'a mut T3, &'a mut T4) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2, T3, T4, T5> TupleMut for (T1, T2, T3, T4, T5)

Source§

type Mut<'a> = (&'a mut T1, &'a mut T2, &'a mut T3, &'a mut T4, &'a mut T5) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2, T3, T4, T5, T6> TupleMut for (T1, T2, T3, T4, T5, T6)

Source§

type Mut<'a> = (&'a mut T1, &'a mut T2, &'a mut T3, &'a mut T4, &'a mut T5, &'a mut T6) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2, T3, T4, T5, T6, T7> TupleMut for (T1, T2, T3, T4, T5, T6, T7)

Source§

type Mut<'a> = (&'a mut T1, &'a mut T2, &'a mut T3, &'a mut T4, &'a mut T5, &'a mut T6, &'a mut T7) where Self: 'a

Source§

fn tuple_mut(&mut self) -> Self::Mut<'_>

Source§

impl<T1, T2, T3, T4, T5, T6, T7, T8> TupleMut for (T1, T2, T3, T4, T5, T6, T7, T8)

Implementors§