1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use core::marker::PhantomData;
use core::pin::Pin;

// Reference gateway
pub trait RefDef<'this> {
    type Type;
}

pub struct Mut<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for Mut<T>
where
    T: 'this,
{
    type Type = &'this mut T;
}

pub struct OptionMut<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for OptionMut<T>
where
    T: 'this,
{
    type Type = Option<&'this mut T>;
}

pub struct Ref<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for Ref<T>
where
    T: 'this,
{
    type Type = &'this T;
}

pub struct OptionRef<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for OptionRef<T>
where
    T: 'this,
{
    type Type = Option<&'this T>;
}

pub struct PinMut<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for PinMut<T>
where
    T: 'this,
{
    type Type = Pin<&'this mut T>;
}

pub struct OptionPinMut<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for OptionPinMut<T>
where
    T: 'this,
{
    type Type = Option<Pin<&'this mut T>>;
}

pub struct PinRef<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for PinRef<T>
where
    T: 'this,
{
    type Type = Pin<&'this T>;
}

pub struct OptionPinRef<T: ?Sized>(PhantomData<T>);
impl<'this, T: ?Sized> RefDef<'this> for OptionPinRef<T>
where
    T: 'this,
{
    type Type = Option<Pin<&'this T>>;
}