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
macro_rules! m_init {
    ($($Tuple:ident $Arr:ident { $($T:ident . $t:ident . $idx:tt),* } )*) => ($(
        impl<$($T),*> $Tuple<$($T),*> {
            pub fn as_refs(&self) -> $Tuple<$(&$T),*> {
                $Tuple( $( &self.$idx ),* )
            }
            pub fn as_mut_refs(&mut self) -> $Tuple<$(&mut $T),*> {
                $Tuple( $( &mut self.$idx ),* )
            }
        }
        impl<$($T),*> Clone for $Tuple<$($T),*> where $( $T: Clone ),* {
            #[inline(always)]
            fn clone(&self) -> Self {
                $Tuple( $( self.$idx.clone() ),* )
            }
        }
        impl<$($T),*> Copy for $Tuple<$($T),*> where $( $T: Copy ),* {}
        
        impl<$($T),*> PartialEq for $Tuple<$($T),*> where $( $T: PartialEq ),* {
            #[inline(always)]
            fn eq(&self, other: &Self) -> bool {
                $( self.$idx == other.$idx)&&*
            }
        }
        impl<$($T),*> Eq for $Tuple<$($T),*> where $( $T: Eq ),* {}
        impl<$($T),*> fmt::Debug for $Tuple<$($T),*> where $( $T: fmt::Debug ),* {
            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                f.debug_tuple(stringify!($Tuple))
             $( .field(&self.$idx) )*
                .finish()
            }
        }
        impl<$($T),*> Default for $Tuple<$($T),*> where $( $T: Default ),* {
            #[inline(always)]
            fn default() -> Self {
                $Tuple( $( $T::default() ),* )
            }
        }
        impl<$($T),*> From<u16> for $Tuple<$($T),*> where $( $T: From<u16> ),* {
            #[inline(always)]
            fn from(value: u16) -> Self {
                $Tuple( $( $T::from(value) ),* )
            }
        }
    )*)
}

use core::fmt;
use super::*;
impl_tuple!(m_init);