TupleRef

Trait TupleRef 

Source
pub trait TupleRef {
    type Ref<'a>
       where Self: 'a;

    // Required method
    fn tuple_ref(&self) -> Self::Ref<'_>;
}
Expand description

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

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

§Examples

use tuplities_ref::TupleRef;

let tuple = (1, "hello".to_string(), vec![1, 2, 3]);
let refs = tuple.tuple_ref();
assert_eq!(refs, (&1, &"hello".to_string(), &vec![1, 2, 3]));

Part of the tuplities crate.

Required Associated Types§

Source

type Ref<'a> where Self: 'a

The type of a tuple containing references to each element.

Required Methods§

Source

fn tuple_ref(&self) -> Self::Ref<'_>

Returns a tuple of references to each element.

§Examples
use tuplities_ref::TupleRef;

let tuple = (42, "world");
let refs = tuple.tuple_ref();
assert_eq!(refs, (&42, &"world"));

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 TupleRef for ()

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

impl<T1> TupleRef for (T1,)

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Source§

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

Source§

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

Source§

fn tuple_ref(&self) -> Self::Ref<'_>

Implementors§