generic_std/
reference.rs

1//! HKT forms for references.
2
3use crate::plug::{PlugLifetime, PlugType};
4use std::marker::PhantomData;
5
6/// HKT `&'a T` with a lifetime and a type slot.
7pub struct H2Reference;
8
9impl<'a> PlugLifetime<'a> for H2Reference {
10    type T = H1Reference<'a>;
11}
12
13/// HKT `&'a T` with a type slot.
14pub struct H1Reference<'a>(PhantomData<&'a ()>);
15
16impl<'a, T> PlugType<T> for H1Reference<'a>
17where
18    T: 'a + ?Sized,
19{
20    type T = &'a T;
21}
22
23/// HKT `&'a T` with a lifetime slot.
24pub struct TypedH1Reference<T>(PhantomData<T>)
25where
26    T: ?Sized;
27
28impl<'a, T> PlugLifetime<'a> for TypedH1Reference<T>
29where
30    T: 'a + ?Sized,
31{
32    type T = &'a T;
33}