File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 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 {
100100 }
101101 }
102102 }
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+ }
103123 }
104124}
105125
@@ -179,3 +199,23 @@ macro_rules! last_type {
179199}
180200
181201tuple_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