tuple/
m_init.rs

1macro_rules! m_init {
2    ($($Tuple:ident $Arr:ident { $($T:ident . $t:ident . $idx:tt),* } )*) => ($(
3        impl<$($T),*> $Tuple<$($T),*> {
4            pub fn as_refs(&self) -> $Tuple<$(&$T),*> {
5                $Tuple( $( &self.$idx ),* )
6            }
7            pub fn as_mut_refs(&mut self) -> $Tuple<$(&mut $T),*> {
8                $Tuple( $( &mut self.$idx ),* )
9            }
10        }
11        impl<$($T),*> Clone for $Tuple<$($T),*> where $( $T: Clone ),* {
12            #[inline(always)]
13            fn clone(&self) -> Self {
14                $Tuple( $( self.$idx.clone() ),* )
15            }
16        }
17        impl<$($T),*> Copy for $Tuple<$($T),*> where $( $T: Copy ),* {}
18        
19        impl<$($T),*> PartialEq for $Tuple<$($T),*> where $( $T: PartialEq ),* {
20            #[inline(always)]
21            fn eq(&self, other: &Self) -> bool {
22                $( self.$idx == other.$idx)&&*
23            }
24        }
25        impl<$($T),*> Eq for $Tuple<$($T),*> where $( $T: Eq ),* {}
26        impl<$($T),*> fmt::Debug for $Tuple<$($T),*> where $( $T: fmt::Debug ),* {
27            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28                f.debug_tuple(stringify!($Tuple))
29             $( .field(&self.$idx) )*
30                .finish()
31            }
32        }
33        impl<$($T),*> Default for $Tuple<$($T),*> where $( $T: Default ),* {
34            #[inline(always)]
35            fn default() -> Self {
36                $Tuple( $( $T::default() ),* )
37            }
38        }
39        impl<$($T),*> From<u16> for $Tuple<$($T),*> where $( $T: From<u16> ),* {
40            #[inline(always)]
41            fn from(value: u16) -> Self {
42                $Tuple( $( $T::from(value) ),* )
43            }
44        }
45    )*)
46}
47
48use core::fmt;
49use super::*;
50impl_tuple!(m_init);