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
#![allow(non_snake_case)]

macro_rules! declare_tuple {
($tconstr:ident[$( $tparam:ident ),* $(,)? ]) => (
    /// Ffi-safe equivalent of tuples.
    #[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash,StableAbi)]
    #[repr(C)]
    #[sabi(inside_abi_stable_crate)]
    pub struct $tconstr< $($tparam,)* > (
        $(pub $tparam,)*
    );

    impl_into_rust_repr! {
        impl[ $($tparam,)* ] Into<( $($tparam,)* )> for $tconstr< $($tparam,)* > {
            fn(this){
                let $tconstr($($tparam,)*)=this;
                ($($tparam,)*)
            }
        }
    }

    impl_from_rust_repr! {
        impl[ $($tparam,)* ] From<( $($tparam,)* )> for $tconstr< $($tparam,)* > {
            fn(this){
                let ($($tparam,)*)=this;
                $tconstr ( $($tparam),* )
            }
        }
    }


)}

declare_tuple! {
    Tuple1[
        A,
    ]
}

declare_tuple! {
    Tuple2[
        A,
        B,
    ]
}

declare_tuple! {
    Tuple3[
        A,
        B,
        C,
    ]
}

declare_tuple! {
    Tuple4[
        A,
        B,
        C,
        D,
    ]
}