@@ -5,21 +5,17 @@ use crate::cmp::*;
55
66// macro for implementing n-ary tuple functions and operations
77macro_rules! tuple_impls {
8- ( $(
9- $Tuple: ident {
10- $( ( $idx: tt) -> $T: ident) +
11- }
12- ) +) => {
8+ ( $( $Tuple: ident( $( $T: ident ) + ) ) + ) => {
139 $(
1410 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1511 impl <$( $T: PartialEq ) ,+> PartialEq for ( $( $T, ) +) where last_type!( $( $T, ) +) : ?Sized {
1612 #[ inline]
1713 fn eq( & self , other: & ( $( $T, ) +) ) -> bool {
18- $( self . $idx == other. $idx ) &&+
14+ $( $ { ignore ( T ) } self . ${ index ( ) } == other. ${ index ( ) } ) &&+
1915 }
2016 #[ inline]
2117 fn ne( & self , other: & ( $( $T, ) +) ) -> bool {
22- $( self . $idx != other. $idx ) ||+
18+ $( $ { ignore ( T ) } self . ${ index ( ) } != other. ${ index ( ) } ) ||+
2319 }
2420 }
2521
@@ -28,34 +24,36 @@ macro_rules! tuple_impls {
2824
2925 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
3026 impl <$( $T: PartialOrd + PartialEq ) ,+> PartialOrd for ( $( $T, ) +)
31- where last_type!( $( $T, ) +) : ?Sized {
27+ where
28+ last_type!( $( $T, ) +) : ?Sized
29+ {
3230 #[ inline]
3331 fn partial_cmp( & self , other: & ( $( $T, ) +) ) -> Option <Ordering > {
34- lexical_partial_cmp!( $( self . $idx , other. $idx ) ,+)
32+ lexical_partial_cmp!( $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
3533 }
3634 #[ inline]
3735 fn lt( & self , other: & ( $( $T, ) +) ) -> bool {
38- lexical_ord!( lt, $( self . $idx , other. $idx ) ,+)
36+ lexical_ord!( lt, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
3937 }
4038 #[ inline]
4139 fn le( & self , other: & ( $( $T, ) +) ) -> bool {
42- lexical_ord!( le, $( self . $idx , other. $idx ) ,+)
40+ lexical_ord!( le, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
4341 }
4442 #[ inline]
4543 fn ge( & self , other: & ( $( $T, ) +) ) -> bool {
46- lexical_ord!( ge, $( self . $idx , other. $idx ) ,+)
44+ lexical_ord!( ge, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
4745 }
4846 #[ inline]
4947 fn gt( & self , other: & ( $( $T, ) +) ) -> bool {
50- lexical_ord!( gt, $( self . $idx , other. $idx ) ,+)
48+ lexical_ord!( gt, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
5149 }
5250 }
5351
5452 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
5553 impl <$( $T: Ord ) ,+> Ord for ( $( $T, ) +) where last_type!( $( $T, ) +) : ?Sized {
5654 #[ inline]
5755 fn cmp( & self , other: & ( $( $T, ) +) ) -> Ordering {
58- lexical_cmp!( $( self . $idx , other. $idx ) ,+)
56+ lexical_cmp!( $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
5957 }
6058 }
6159
@@ -108,106 +106,16 @@ macro_rules! last_type {
108106}
109107
110108tuple_impls ! {
111- Tuple1 {
112- ( 0 ) -> A
113- }
114- Tuple2 {
115- ( 0 ) -> A
116- ( 1 ) -> B
117- }
118- Tuple3 {
119- ( 0 ) -> A
120- ( 1 ) -> B
121- ( 2 ) -> C
122- }
123- Tuple4 {
124- ( 0 ) -> A
125- ( 1 ) -> B
126- ( 2 ) -> C
127- ( 3 ) -> D
128- }
129- Tuple5 {
130- ( 0 ) -> A
131- ( 1 ) -> B
132- ( 2 ) -> C
133- ( 3 ) -> D
134- ( 4 ) -> E
135- }
136- Tuple6 {
137- ( 0 ) -> A
138- ( 1 ) -> B
139- ( 2 ) -> C
140- ( 3 ) -> D
141- ( 4 ) -> E
142- ( 5 ) -> F
143- }
144- Tuple7 {
145- ( 0 ) -> A
146- ( 1 ) -> B
147- ( 2 ) -> C
148- ( 3 ) -> D
149- ( 4 ) -> E
150- ( 5 ) -> F
151- ( 6 ) -> G
152- }
153- Tuple8 {
154- ( 0 ) -> A
155- ( 1 ) -> B
156- ( 2 ) -> C
157- ( 3 ) -> D
158- ( 4 ) -> E
159- ( 5 ) -> F
160- ( 6 ) -> G
161- ( 7 ) -> H
162- }
163- Tuple9 {
164- ( 0 ) -> A
165- ( 1 ) -> B
166- ( 2 ) -> C
167- ( 3 ) -> D
168- ( 4 ) -> E
169- ( 5 ) -> F
170- ( 6 ) -> G
171- ( 7 ) -> H
172- ( 8 ) -> I
173- }
174- Tuple10 {
175- ( 0 ) -> A
176- ( 1 ) -> B
177- ( 2 ) -> C
178- ( 3 ) -> D
179- ( 4 ) -> E
180- ( 5 ) -> F
181- ( 6 ) -> G
182- ( 7 ) -> H
183- ( 8 ) -> I
184- ( 9 ) -> J
185- }
186- Tuple11 {
187- ( 0 ) -> A
188- ( 1 ) -> B
189- ( 2 ) -> C
190- ( 3 ) -> D
191- ( 4 ) -> E
192- ( 5 ) -> F
193- ( 6 ) -> G
194- ( 7 ) -> H
195- ( 8 ) -> I
196- ( 9 ) -> J
197- ( 10 ) -> K
198- }
199- Tuple12 {
200- ( 0 ) -> A
201- ( 1 ) -> B
202- ( 2 ) -> C
203- ( 3 ) -> D
204- ( 4 ) -> E
205- ( 5 ) -> F
206- ( 6 ) -> G
207- ( 7 ) -> H
208- ( 8 ) -> I
209- ( 9 ) -> J
210- ( 10 ) -> K
211- ( 11 ) -> L
212- }
109+ Tuple1 ( A )
110+ Tuple2 ( A B )
111+ Tuple3 ( A B C )
112+ Tuple4 ( A B C D )
113+ Tuple5 ( A B C D E )
114+ Tuple6 ( A B C D E F )
115+ Tuple7 ( A B C D E F G )
116+ Tuple8 ( A B C D E F G H )
117+ Tuple9 ( A B C D E F G H I )
118+ Tuple10 ( A B C D E F G H I J )
119+ Tuple11 ( A B C D E F G H I J K )
120+ Tuple12 ( A B C D E F G H I J K L )
213121}
0 commit comments