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
#![no_std]
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 Tuple {
fn arity(&self) -> usize;
}
impl Tuple for () {
fn arity(&self) -> usize {
0
}
}
impl<T> Tuple for (T,) {
fn arity(&self) -> usize {
1
}
}
pub trait TupleSame<T>: Tuple {}
impl<T> TupleSame<T> for () {}
impl<T> TupleSame<T> for (T,) {}
include!(concat!(env!("OUT_DIR"), "/tuple_impl.rs"));
pub mod tuple_n {
use crate::*;
pub trait Tuple0: Tuple {}
impl Tuple0 for () {}
pub trait Tuple1: Tuple {
type Item0;
}
impl<T> Tuple1 for (T,) {
type Item0 = T;
}
include!(concat!(env!("OUT_DIR"), "/tuple_n.rs"));
}
include!(concat!(env!("OUT_DIR"), "/tuple_alias.rs"));
#[cfg(feature = "re-exports")]
pub use tuple_n::*;
#[cfg(feature = "tuple_iter")]
pub mod tuple_iter;
#[cfg(all(feature = "tuple_iter", feature = "re-exports"))]
pub use tuple_iter::*;
#[cfg(feature = "tuple_map")]
pub mod tuple_map;
#[cfg(all(feature = "tuple_map", feature = "re-exports"))]
pub use tuple_map::*;