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
105
106
//! To make our custom asynchronous closures general
//! enough to be reused in different parts of our
//! API, we needed to make some traits and types generic
//! over a lifetime-parametrized type. This is impossible in
//! Rust, so we came up to [`WithLifetime`] trait that
//! allows to express lifetime-parametrized types
//! via GATs.
//!
//! There are some pre-defined implementations
//! of [`WithLifetime`] to express owned values,
//! mutable and immutable references, but if you want
//! to use it with some non-trivial lifetime-parametrized
//! types we don't support out of the box, you can
//! implement the trait for your own types.
//!
//! - [`Owned`] type can be used to define lifetime-parametrized
//! type that doesn't depend on its parameter.
//! - [`Ref`] type can be used to define reference type
//! parametrized by its lifetime.
//! - [`Mut`] type can be used to define mutable reference
//! type paramethrized by its lifetime.
//! - Tuple of [`WithLifetime`] types is [`WithLifetime`] type
//! representing tuple.
/// The trait that allows to express lifetime-parametrized
/// types as plain types.
///
/// A type implementing this trait is a marker type
/// that defines lifetime-parametrized type as its
/// associated type [`Self::Type`].
/// Marker type that represents
/// lifetime-independent type.
///
/// Its associated lifetime-parametrized
/// type is `T` for all lifetimes.
;
/// Marker type that represents
/// reference type parametrized
/// by its lifetime.
;
/// Marker type that represents
/// mutable reference type
/// parametrized by its lifetime.
;
impl_tuples!;