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
107
108
109
110
111
112
113
114
115
116
117
use core::ops::{Deref, DerefMut};
include!("./gen/tuple_as.rs");
pub trait TupleAsRef<'a> {
type OutTuple: 'a;
fn as_ref(&'a self) -> Self::OutTuple;
}
impl<'a, T: 'a> TupleAsRef<'a> for (T,) {
type OutTuple = (&'a T,);
fn as_ref(&'a self) -> Self::OutTuple {
(&self.0,)
}
}
pub trait TupleAsMut<'a> {
type OutTuple: 'a;
fn as_mut(&'a mut self) -> Self::OutTuple;
}
impl<'a, T: 'a> TupleAsMut<'a> for (T,) {
type OutTuple = (&'a mut T,);
fn as_mut(&'a mut self) -> Self::OutTuple {
(&mut self.0,)
}
}
pub trait TupleAsOption {
type OutTuple;
fn as_some(self) -> Self::OutTuple;
}
impl<T> TupleAsOption for (T,) {
type OutTuple = (Option<T>,);
fn as_some(self) -> Self::OutTuple {
(Some(self.0),)
}
}
pub trait TupleAsResultOk<E> {
type OutTuple;
fn as_ok(self) -> Self::OutTuple;
}
pub trait TupleAsResultErr<T> {
type OutTuple;
fn as_err(self) -> Self::OutTuple;
}
impl<T, E> TupleAsResultOk<E> for (T,) {
type OutTuple = (Result<T, E>,);
fn as_ok(self) -> Self::OutTuple {
(Ok(self.0),)
}
}
impl<T, O> TupleAsResultErr<O> for (T,) {
type OutTuple = (Result<O, T>,);
fn as_err(self) -> Self::OutTuple {
(Err(self.0),)
}
}
pub trait TupleAsDeref<'a> {
type OutTuple: 'a;
fn as_deref(&'a self) -> Self::OutTuple;
}
impl<'a, T: 'a + Deref> TupleAsDeref<'a> for (T,) {
type OutTuple = (&'a <T as Deref>::Target,);
fn as_deref(&'a self) -> Self::OutTuple {
(self.0.deref(),)
}
}
pub trait TupleAsDerefMut<'a> {
type OutTuple: 'a;
fn as_deref_mut(&'a mut self) -> Self::OutTuple;
}
impl<'a, T: 'a + DerefMut> TupleAsDerefMut<'a> for (T,) {
type OutTuple = (&'a mut <T as Deref>::Target,);
fn as_deref_mut(&'a mut self) -> Self::OutTuple {
(self.0.deref_mut(),)
}
}