[][src]Trait structural::utils::DerefNested

pub unsafe trait DerefNested<'a> {
    type Dereffed: 'a;
    unsafe fn deref_nested(self) -> Self::Dereffed;
}

For dereferencing tuples of pointers into tuples of mutable references.

Safety

The mutable raw pointers in Self must be dereferenced into mutable references.

The Dereffed associated type must have the same structure as Self, in which the mutable pointers are replaced with mutable references with the 'a lifetime.

Example

use structural::field::InfallibleAccess;
use structural::utils::DerefNested;

let mut left  = 100_u32;
let mut middle = 200_u32;
let mut right = 300_u32;

type ResRawPtr = Result<*mut u32, InfallibleAccess>;
type ResMutRef<'a> = Result<&'a mut u32, InfallibleAccess>;

let tuple: ((ResRawPtr, ResRawPtr),ResRawPtr) =
    ((Ok(&mut left as *mut _), Ok(&mut middle as *mut _)), Ok(&mut right as *mut _));
unsafe{
    let mutref_tuple: ((ResMutRef<'_>, ResMutRef<'_>), ResMutRef<'_>) =
        tuple.deref_nested();
    assert_eq!(mutref_tuple, ((Ok(&mut 100), Ok(&mut 200)), Ok(&mut 300)));
}

Associated Types

type Dereffed: 'a

A type with the same structure as Self, in which the mutable pointers are replaced with mutable references with the 'a lifetime.

Loading content...

Required methods

unsafe fn deref_nested(self) -> Self::Dereffed

Dereferences the mutable pointers in this into mutable references.

Safety

The raw pointers in Self must point to non-dangling, initialized values, which are valid for the 'a lifetime.

Loading content...

Implementations on Foreign Types

impl<'a> DerefNested<'a> for ()[src]

type Dereffed = ()

impl<'a, F0> DerefNested<'a> for (F0,) where
    F0: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed,)

impl<'a, F0, F1> DerefNested<'a> for (F0, F1) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed)

impl<'a, F0, F1, F2> DerefNested<'a> for (F0, F1, F2) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>,
    F2: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed, F2::Dereffed)

impl<'a, F0, F1, F2, F3> DerefNested<'a> for (F0, F1, F2, F3) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>,
    F2: 'a + DerefNested<'a>,
    F3: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed, F2::Dereffed, F3::Dereffed)

impl<'a, F0, F1, F2, F3, F4> DerefNested<'a> for (F0, F1, F2, F3, F4) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>,
    F2: 'a + DerefNested<'a>,
    F3: 'a + DerefNested<'a>,
    F4: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed, F2::Dereffed, F3::Dereffed, F4::Dereffed)

impl<'a, F0, F1, F2, F3, F4, F5> DerefNested<'a> for (F0, F1, F2, F3, F4, F5) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>,
    F2: 'a + DerefNested<'a>,
    F3: 'a + DerefNested<'a>,
    F4: 'a + DerefNested<'a>,
    F5: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed, F2::Dereffed, F3::Dereffed, F4::Dereffed, F5::Dereffed)

impl<'a, F0, F1, F2, F3, F4, F5, F6> DerefNested<'a> for (F0, F1, F2, F3, F4, F5, F6) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>,
    F2: 'a + DerefNested<'a>,
    F3: 'a + DerefNested<'a>,
    F4: 'a + DerefNested<'a>,
    F5: 'a + DerefNested<'a>,
    F6: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed, F2::Dereffed, F3::Dereffed, F4::Dereffed, F5::Dereffed, F6::Dereffed)

impl<'a, F0, F1, F2, F3, F4, F5, F6, F7> DerefNested<'a> for (F0, F1, F2, F3, F4, F5, F6, F7) where
    F0: 'a + DerefNested<'a>,
    F1: 'a + DerefNested<'a>,
    F2: 'a + DerefNested<'a>,
    F3: 'a + DerefNested<'a>,
    F4: 'a + DerefNested<'a>,
    F5: 'a + DerefNested<'a>,
    F6: 'a + DerefNested<'a>,
    F7: 'a + DerefNested<'a>, 
[src]

type Dereffed = (F0::Dereffed, F1::Dereffed, F2::Dereffed, F3::Dereffed, F4::Dereffed, F5::Dereffed, F6::Dereffed, F7::Dereffed)

impl<'a, T: 'a, E: 'a> DerefNested<'a> for Result<*mut T, E>[src]

type Dereffed = Result<&'a mut T, E>

Loading content...

Implementors

Loading content...