pub trait GhostBorrow<'a, 'brand> {
    type Result;

    // Required method
    fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result;
}
Expand description

A trait for implementing multiple borrows for any number of arguments, using a GhostToken<'a, 'brand>.

Implemented for a mixture of tuple and array types.

Required Associated Types§

source

type Result

The references you get as a result.

For example, if Self is (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>) then Result is (&'a T0, &'a T1).

Required Methods§

source

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

Borrows any number of GhostCells at the same time.

§Example
use ghost_cell::{GhostToken, GhostCell, GhostBorrow};

let value = GhostToken::new(|mut token| {
    let cell1 = GhostCell::new(42);
    let cell2 = GhostCell::new(47);

    let (reference1, reference2): (&i32, &i32) = (&cell1, &cell2).borrow(&token);

    (*reference1, *reference2)
});

assert_eq!((42, 47), value);

Implementations on Foreign Types§

source§

impl<'a, 'brand, T0> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>,)
where T0: ?Sized,

§

type Result = &'a (T0,)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>)
where T1: ?Sized,

§

type Result = &'a (T0, T1)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>)
where T2: ?Sized,

§

type Result = &'a (T0, T1, T2)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2, T3> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>)
where T3: ?Sized,

§

type Result = &'a (T0, T1, T2, T3)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2, T3, T4> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>)
where T4: ?Sized,

§

type Result = &'a (T0, T1, T2, T3, T4)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>)
where T5: ?Sized,

§

type Result = &'a (T0, T1, T2, T3, T4, T5)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5, T6> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>, GhostCell<'brand, T6>)
where T6: ?Sized,

§

type Result = &'a (T0, T1, T2, T3, T4, T5, T6)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5, T6, T7> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>, GhostCell<'brand, T6>, GhostCell<'brand, T7>)
where T7: ?Sized,

§

type Result = &'a (T0, T1, T2, T3, T4, T5, T6, T7)

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5, T6, T7, T8> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>, GhostCell<'brand, T6>, GhostCell<'brand, T7>, GhostCell<'brand, T8>)
where T8: ?Sized,

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>, GhostCell<'brand, T6>, GhostCell<'brand, T7>, GhostCell<'brand, T8>, GhostCell<'brand, T9>)
where T9: ?Sized,

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, TA> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>, GhostCell<'brand, T6>, GhostCell<'brand, T7>, GhostCell<'brand, T8>, GhostCell<'brand, T9>, GhostCell<'brand, TA>)
where TA: ?Sized,

source§

impl<'a, 'brand, T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, TA, TB> GhostBorrow<'a, 'brand> for &'a (GhostCell<'brand, T0>, GhostCell<'brand, T1>, GhostCell<'brand, T2>, GhostCell<'brand, T3>, GhostCell<'brand, T4>, GhostCell<'brand, T5>, GhostCell<'brand, T6>, GhostCell<'brand, T7>, GhostCell<'brand, T8>, GhostCell<'brand, T9>, GhostCell<'brand, TA>, GhostCell<'brand, TB>)
where TB: ?Sized,

source§

impl<'a, 'brand, T0: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>,)

§

type Result = (&'a T0,)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>)

§

type Result = (&'a T0, &'a T1)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>)

§

type Result = (&'a T0, &'a T1, &'a T2)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4, &'a T5)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized, T6: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>, &'a GhostCell<'brand, T6>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4, &'a T5, &'a T6)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized, T6: ?Sized, T7: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>, &'a GhostCell<'brand, T6>, &'a GhostCell<'brand, T7>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4, &'a T5, &'a T6, &'a T7)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized, T6: ?Sized, T7: ?Sized, T8: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>, &'a GhostCell<'brand, T6>, &'a GhostCell<'brand, T7>, &'a GhostCell<'brand, T8>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4, &'a T5, &'a T6, &'a T7, &'a T8)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized, T6: ?Sized, T7: ?Sized, T8: ?Sized, T9: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>, &'a GhostCell<'brand, T6>, &'a GhostCell<'brand, T7>, &'a GhostCell<'brand, T8>, &'a GhostCell<'brand, T9>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4, &'a T5, &'a T6, &'a T7, &'a T8, &'a T9)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized, T6: ?Sized, T7: ?Sized, T8: ?Sized, T9: ?Sized, TA: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>, &'a GhostCell<'brand, T6>, &'a GhostCell<'brand, T7>, &'a GhostCell<'brand, T8>, &'a GhostCell<'brand, T9>, &'a GhostCell<'brand, TA>)

§

type Result = (&'a T0, &'a T1, &'a T2, &'a T3, &'a T4, &'a T5, &'a T6, &'a T7, &'a T8, &'a T9, &'a TA)

source§

fn borrow(self, token: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T0: ?Sized, T1: ?Sized, T2: ?Sized, T3: ?Sized, T4: ?Sized, T5: ?Sized, T6: ?Sized, T7: ?Sized, T8: ?Sized, T9: ?Sized, TA: ?Sized, TB: ?Sized> GhostBorrow<'a, 'brand> for (&'a GhostCell<'brand, T0>, &'a GhostCell<'brand, T1>, &'a GhostCell<'brand, T2>, &'a GhostCell<'brand, T3>, &'a GhostCell<'brand, T4>, &'a GhostCell<'brand, T5>, &'a GhostCell<'brand, T6>, &'a GhostCell<'brand, T7>, &'a GhostCell<'brand, T8>, &'a GhostCell<'brand, T9>, &'a GhostCell<'brand, TA>, &'a GhostCell<'brand, TB>)

source§

impl<'a, 'brand, T> GhostBorrow<'a, 'brand> for &'a [GhostCell<'brand, T>]

§

type Result = &'a [T]

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T, const N: usize> GhostBorrow<'a, 'brand> for &'a [GhostCell<'brand, T>; N]

§

type Result = &'a [T; N]

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

source§

impl<'a, 'brand, T: ?Sized, const N: usize> GhostBorrow<'a, 'brand> for [&'a GhostCell<'brand, T>; N]

§

type Result = [&'a T; N]

source§

fn borrow(self, _: &'a GhostToken<'brand>) -> Self::Result

Implementors§