topcoat_runtime/surrogate/
tuple.rs1use crate::{Surrogate, Surrogated};
2
3impl Surrogated for () {
4 type Surrogate = ();
5 fn into_surrogate(self) -> Self::Surrogate {}
6}
7
8impl Surrogate for () {
9 type Real = ();
10 fn into_real(self) -> Self::Real {}
11}
12
13macro_rules! impl_tuple_surrogate {
14 ($($t:ident $idx:tt),+ $(,)?) => {
15 impl<$($t),+> Surrogated for ($($t,)+)
16 where
17 $($t: Surrogated,)+
18 {
19 type Surrogate = ($(<$t as Surrogated>::Surrogate,)+);
20
21 fn into_surrogate(self) -> Self::Surrogate {
22 ($(self.$idx.into_surrogate(),)+)
23 }
24 }
25
26 impl<$($t),+> Surrogate for ($($t,)+)
27 where
28 $($t: Surrogate,)+
29 {
30 type Real = ($(<$t as Surrogate>::Real,)+);
31
32 fn into_real(self) -> Self::Real {
33 ($(self.$idx.into_real(),)+)
34 }
35 }
36 };
37}
38
39impl_tuple_surrogate!(T1 0);
40impl_tuple_surrogate!(T1 0, T2 1);
41impl_tuple_surrogate!(T1 0, T2 1, T3 2);
42impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3);
43impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4);
44impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4, T6 5);
45impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4, T6 5, T7 6);
46impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4, T6 5, T7 6, T8 7);
47impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4, T6 5, T7 6, T8 7, T9 8);
48impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4, T6 5, T7 6, T8 7, T9 8, T10 9);
49impl_tuple_surrogate!(T1 0, T2 1, T3 2, T4 3, T5 4, T6 5, T7 6, T8 7, T9 8, T10 9, T11 10);
50impl_tuple_surrogate!(
51 T1 0, T2 1, T3 2, T4 3, T5 4, T6 5, T7 6, T8 7, T9 8, T10 9, T11 10, T12 11,
52);