@@ -5,21 +5,17 @@ use crate::cmp::*;
5
5
6
6
// macro for implementing n-ary tuple functions and operations
7
7
macro_rules! tuple_impls {
8
- ( $(
9
- $Tuple: ident {
10
- $( ( $idx: tt) -> $T: ident) +
11
- }
12
- ) +) => {
8
+ ( $( $Tuple: ident( $( $T: ident ) + ) ) + ) => {
13
9
$(
14
10
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
15
11
impl <$( $T: PartialEq ) ,+> PartialEq for ( $( $T, ) +) where last_type!( $( $T, ) +) : ?Sized {
16
12
#[ inline]
17
13
fn eq( & self , other: & ( $( $T, ) +) ) -> bool {
18
- $( self . $idx == other. $idx ) &&+
14
+ $( $ { ignore ( T ) } self . ${ index ( ) } == other. ${ index ( ) } ) &&+
19
15
}
20
16
#[ inline]
21
17
fn ne( & self , other: & ( $( $T, ) +) ) -> bool {
22
- $( self . $idx != other. $idx ) ||+
18
+ $( $ { ignore ( T ) } self . ${ index ( ) } != other. ${ index ( ) } ) ||+
23
19
}
24
20
}
25
21
@@ -28,34 +24,36 @@ macro_rules! tuple_impls {
28
24
29
25
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
30
26
impl <$( $T: PartialOrd + PartialEq ) ,+> PartialOrd for ( $( $T, ) +)
31
- where last_type!( $( $T, ) +) : ?Sized {
27
+ where
28
+ last_type!( $( $T, ) +) : ?Sized
29
+ {
32
30
#[ inline]
33
31
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 ( ) } ) ,+)
35
33
}
36
34
#[ inline]
37
35
fn lt( & self , other: & ( $( $T, ) +) ) -> bool {
38
- lexical_ord!( lt, $( self . $idx , other. $idx ) ,+)
36
+ lexical_ord!( lt, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
39
37
}
40
38
#[ inline]
41
39
fn le( & self , other: & ( $( $T, ) +) ) -> bool {
42
- lexical_ord!( le, $( self . $idx , other. $idx ) ,+)
40
+ lexical_ord!( le, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
43
41
}
44
42
#[ inline]
45
43
fn ge( & self , other: & ( $( $T, ) +) ) -> bool {
46
- lexical_ord!( ge, $( self . $idx , other. $idx ) ,+)
44
+ lexical_ord!( ge, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
47
45
}
48
46
#[ inline]
49
47
fn gt( & self , other: & ( $( $T, ) +) ) -> bool {
50
- lexical_ord!( gt, $( self . $idx , other. $idx ) ,+)
48
+ lexical_ord!( gt, $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
51
49
}
52
50
}
53
51
54
52
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
55
53
impl <$( $T: Ord ) ,+> Ord for ( $( $T, ) +) where last_type!( $( $T, ) +) : ?Sized {
56
54
#[ inline]
57
55
fn cmp( & self , other: & ( $( $T, ) +) ) -> Ordering {
58
- lexical_cmp!( $( self . $idx , other. $idx ) ,+)
56
+ lexical_cmp!( $( $ { ignore ( T ) } self . ${ index ( ) } , other. ${ index ( ) } ) ,+)
59
57
}
60
58
}
61
59
@@ -108,106 +106,16 @@ macro_rules! last_type {
108
106
}
109
107
110
108
tuple_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 )
213
121
}
0 commit comments