File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,26 @@ macro_rules! tuple_impls {
100
100
}
101
101
}
102
102
}
103
+
104
+ #[ stable( feature = "array_tuple_conv" , since = "1.63.0" ) ]
105
+ impl <T > From <[ T ; count!( $( $T) +) ] > for ( $( ${ ignore( T ) } T , ) +) {
106
+ #[ inline]
107
+ #[ allow( non_snake_case) ]
108
+ fn from( array: [ T ; count!( $( $T) +) ] ) -> Self {
109
+ let [ $( $T, ) +] = array;
110
+ ( $( $T, ) +)
111
+ }
112
+ }
113
+
114
+ #[ stable( feature = "array_tuple_conv" , since = "1.63.0" ) ]
115
+ impl <T > From <( $( ${ ignore( T ) } T , ) +) > for [ T ; count!( $( $T) +) ] {
116
+ #[ inline]
117
+ #[ allow( non_snake_case) ]
118
+ fn from( tuple: ( $( ${ ignore( T ) } T , ) +) ) -> Self {
119
+ let ( $( $T, ) +) = tuple;
120
+ [ $( $T, ) +]
121
+ }
122
+ }
103
123
}
104
124
}
105
125
@@ -179,3 +199,23 @@ macro_rules! last_type {
179
199
}
180
200
181
201
tuple_impls ! ( E D C B A Z Y X W V U T ) ;
202
+
203
+ macro_rules! count {
204
+ ( $( $a: ident) * ) => {
205
+ 0 $( ${ ignore( a) } + 1 ) *
206
+ } ;
207
+ }
208
+
209
+ #[ stable( feature = "array_tuple_conv" , since = "1.63.0" ) ]
210
+ impl < T > From < ( ) > for [ T ; 0 ] {
211
+ fn from ( ( ) : ( ) ) -> Self {
212
+ [ ]
213
+ }
214
+ }
215
+
216
+ #[ stable( feature = "array_tuple_conv" , since = "1.63.0" ) ]
217
+ impl < T > From < [ T ; 0 ] > for ( ) {
218
+ fn from ( [ ] : [ T ; 0 ] ) -> Self {
219
+ ( )
220
+ }
221
+ }
You can’t perform that action at this time.
0 commit comments