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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Wrapper types that impl [`TypeName`] when their generic type `T` is `'static`.

use effectful::SendSync;

use crate::hkt::Marker;

use super::*;

/// Named `T` where `T: 'static`.
#[derive(PartialEq, Clone, Copy, Debug, SendSync)]
#[repr(transparent)]
pub struct OwnedStatic<T: ?Sized>(pub T);

impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Lower<'lt, 'ctx, &'lt &'ctx ()> for OwnedStatic<T> {
    type Lowered = OwnedStatic<T>;
}

impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Raise<'lt, 'ctx, &'lt &'ctx ()> for OwnedStatic<T> {
    type Raised = OwnedStatic<T>;
}

/// Named `&'ctx T` where` T: 'static`.
#[derive(PartialEq, Clone, Copy, Debug, SendSync)]
#[repr(transparent)]
pub struct BorrowedStatic<'ctx, T: ?Sized>(pub &'ctx T);

const _: () = {
    pub struct BorrowedStaticHrt<T: ?Sized>(Marker<T>);

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Lower<'lt, 'ctx, &'lt &'ctx ()>
        for BorrowedStaticHrt<T>
    {
        type Lowered = BorrowedStatic<'ctx, T>;
    }

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Raise<'lt, 'ctx, &'lt &'ctx ()>
        for BorrowedStatic<'ctx, T>
    {
        type Raised = BorrowedStaticHrt<T>;
    }
};

/// Named `&'lt T` where` T: 'static`.
#[derive(PartialEq, Clone, Copy, Debug, SendSync)]
#[repr(transparent)]
pub struct TempBorrowedStatic<'lt, T: ?Sized>(pub &'lt T);

const _: () = {
    pub struct TempBorrowedStaticHrt<T: ?Sized>(Marker<T>);

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Lower<'lt, 'ctx, &'lt &'ctx ()>
        for TempBorrowedStaticHrt<T>
    {
        type Lowered = TempBorrowedStatic<'lt, T>;
    }

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Raise<'lt, 'ctx, &'lt &'ctx ()>
        for TempBorrowedStatic<'lt, T>
    {
        type Raised = TempBorrowedStaticHrt<T>;
    }
};

/// Named `&'ctx mut T` where` T: 'static`.
#[derive(PartialEq, Debug, SendSync)]
#[repr(transparent)]
pub struct BorrowedMutStatic<'ctx, T: ?Sized>(pub &'ctx mut T);

const _: () = {
    pub struct BorrowedMutStaticHrt<T: ?Sized>(Marker<T>);

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Lower<'lt, 'ctx, &'lt &'ctx ()>
        for BorrowedMutStaticHrt<T>
    {
        type Lowered = BorrowedMutStatic<'ctx, T>;
    }

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Raise<'lt, 'ctx, &'lt &'ctx ()>
        for BorrowedMutStatic<'ctx, T>
    {
        type Raised = BorrowedMutStaticHrt<T>;
    }
};

/// Named `&'lt mut T` where` T: 'static`.
#[derive(PartialEq, Debug, SendSync)]
#[repr(transparent)]
pub struct TempBorrowedMutStatic<'lt, T: ?Sized>(pub &'lt mut T);

const _: () = {
    pub struct TempBorrowedMutStaticHrt<T: ?Sized>(Marker<T>);

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Lower<'lt, 'ctx, &'lt &'ctx ()>
        for TempBorrowedMutStaticHrt<T>
    {
        type Lowered = TempBorrowedMutStatic<'lt, T>;
    }

    impl<'lt, 'ctx, T: ?Sized + 'static> type_name::Raise<'lt, 'ctx, &'lt &'ctx ()>
        for TempBorrowedMutStatic<'lt, T>
    {
        type Raised = TempBorrowedMutStaticHrt<T>;
    }
};