@@ -80,36 +80,28 @@ impl<T, U> ImmutableTuple<T, U> for (T, U) {
80
80
}
81
81
82
82
// macro for implementing n-ary tuple functions and operations
83
-
84
83
macro_rules! tuple_impls {
85
84
( $(
86
- ( $move_trait : ident, $immutable_trait : ident ) {
85
+ $Tuple : ident {
87
86
$( ( $get_fn: ident, $get_ref_fn: ident) -> $T: ident {
88
87
$move_pattern: pat, $ref_pattern: pat => $ret: expr
89
88
} ) +
90
89
}
91
90
) +) => {
92
91
$(
93
- pub trait $move_trait <$( $T) ,+> {
92
+ pub trait $Tuple <$( $T) ,+> {
94
93
$( fn $get_fn( self ) -> $T; ) +
94
+ $( fn $get_ref_fn<' a>( & ' a self ) -> & ' a $T; ) +
95
95
}
96
96
97
- impl <$( $T) ,+> $move_trait <$( $T) ,+> for ( $( $T, ) +) {
97
+ impl <$( $T) ,+> $Tuple <$( $T) ,+> for ( $( $T, ) +) {
98
98
$(
99
99
#[ inline]
100
100
fn $get_fn( self ) -> $T {
101
101
let $move_pattern = self ;
102
102
$ret
103
103
}
104
- ) +
105
- }
106
-
107
- pub trait $immutable_trait<$( $T) ,+> {
108
- $( fn $get_ref_fn<' a>( & ' a self ) -> & ' a $T; ) +
109
- }
110
104
111
- impl <$( $T) ,+> $immutable_trait<$( $T) ,+> for ( $( $T, ) +) {
112
- $(
113
105
#[ inline]
114
106
fn $get_ref_fn<' a>( & ' a self ) -> & ' a $T {
115
107
let $ref_pattern = * self ;
@@ -230,46 +222,40 @@ macro_rules! write_tuple {
230
222
}
231
223
232
224
tuple_impls ! {
233
- ( Tuple1 , ImmutableTuple1 ) {
225
+ Tuple1 {
234
226
( n0, n0_ref) -> A { ( a, ) , ( ref a, ) => a }
235
227
}
236
-
237
- ( Tuple2 , ImmutableTuple2 ) {
228
+ Tuple2 {
238
229
( n0, n0_ref) -> A { ( a, _) , ( ref a, _) => a }
239
230
( n1, n1_ref) -> B { ( _, b) , ( _, ref b) => b }
240
231
}
241
-
242
- ( Tuple3 , ImmutableTuple3 ) {
232
+ Tuple3 {
243
233
( n0, n0_ref) -> A { ( a, _, _) , ( ref a, _, _) => a }
244
234
( n1, n1_ref) -> B { ( _, b, _) , ( _, ref b, _) => b }
245
235
( n2, n2_ref) -> C { ( _, _, c) , ( _, _, ref c) => c }
246
236
}
247
-
248
- ( Tuple4 , ImmutableTuple4 ) {
237
+ Tuple4 {
249
238
( n0, n0_ref) -> A { ( a, _, _, _) , ( ref a, _, _, _) => a }
250
239
( n1, n1_ref) -> B { ( _, b, _, _) , ( _, ref b, _, _) => b }
251
240
( n2, n2_ref) -> C { ( _, _, c, _) , ( _, _, ref c, _) => c }
252
241
( n3, n3_ref) -> D { ( _, _, _, d) , ( _, _, _, ref d) => d }
253
242
}
254
-
255
- ( Tuple5 , ImmutableTuple5 ) {
243
+ Tuple5 {
256
244
( n0, n0_ref) -> A { ( a, _, _, _, _) , ( ref a, _, _, _, _) => a }
257
245
( n1, n1_ref) -> B { ( _, b, _, _, _) , ( _, ref b, _, _, _) => b }
258
246
( n2, n2_ref) -> C { ( _, _, c, _, _) , ( _, _, ref c, _, _) => c }
259
247
( n3, n3_ref) -> D { ( _, _, _, d, _) , ( _, _, _, ref d, _) => d }
260
248
( n4, n4_ref) -> E { ( _, _, _, _, e) , ( _, _, _, _, ref e) => e }
261
249
}
262
-
263
- ( Tuple6 , ImmutableTuple6 ) {
250
+ Tuple6 {
264
251
( n0, n0_ref) -> A { ( a, _, _, _, _, _) , ( ref a, _, _, _, _, _) => a }
265
252
( n1, n1_ref) -> B { ( _, b, _, _, _, _) , ( _, ref b, _, _, _, _) => b }
266
253
( n2, n2_ref) -> C { ( _, _, c, _, _, _) , ( _, _, ref c, _, _, _) => c }
267
254
( n3, n3_ref) -> D { ( _, _, _, d, _, _) , ( _, _, _, ref d, _, _) => d }
268
255
( n4, n4_ref) -> E { ( _, _, _, _, e, _) , ( _, _, _, _, ref e, _) => e }
269
256
( n5, n5_ref) -> F { ( _, _, _, _, _, f) , ( _, _, _, _, _, ref f) => f }
270
257
}
271
-
272
- ( Tuple7 , ImmutableTuple7 ) {
258
+ Tuple7 {
273
259
( n0, n0_ref) -> A { ( a, _, _, _, _, _, _) , ( ref a, _, _, _, _, _, _) => a }
274
260
( n1, n1_ref) -> B { ( _, b, _, _, _, _, _) , ( _, ref b, _, _, _, _, _) => b }
275
261
( n2, n2_ref) -> C { ( _, _, c, _, _, _, _) , ( _, _, ref c, _, _, _, _) => c }
@@ -278,8 +264,7 @@ tuple_impls! {
278
264
( n5, n5_ref) -> F { ( _, _, _, _, _, f, _) , ( _, _, _, _, _, ref f, _) => f }
279
265
( n6, n6_ref) -> G { ( _, _, _, _, _, _, g) , ( _, _, _, _, _, _, ref g) => g }
280
266
}
281
-
282
- ( Tuple8 , ImmutableTuple8 ) {
267
+ Tuple8 {
283
268
( n0, n0_ref) -> A { ( a, _, _, _, _, _, _, _) , ( ref a, _, _, _, _, _, _, _) => a }
284
269
( n1, n1_ref) -> B { ( _, b, _, _, _, _, _, _) , ( _, ref b, _, _, _, _, _, _) => b }
285
270
( n2, n2_ref) -> C { ( _, _, c, _, _, _, _, _) , ( _, _, ref c, _, _, _, _, _) => c }
@@ -289,8 +274,7 @@ tuple_impls! {
289
274
( n6, n6_ref) -> G { ( _, _, _, _, _, _, g, _) , ( _, _, _, _, _, _, ref g, _) => g }
290
275
( n7, n7_ref) -> H { ( _, _, _, _, _, _, _, h) , ( _, _, _, _, _, _, _, ref h) => h }
291
276
}
292
-
293
- ( Tuple9 , ImmutableTuple9 ) {
277
+ Tuple9 {
294
278
( n0, n0_ref) -> A { ( a, _, _, _, _, _, _, _, _) , ( ref a, _, _, _, _, _, _, _, _) => a }
295
279
( n1, n1_ref) -> B { ( _, b, _, _, _, _, _, _, _) , ( _, ref b, _, _, _, _, _, _, _) => b }
296
280
( n2, n2_ref) -> C { ( _, _, c, _, _, _, _, _, _) , ( _, _, ref c, _, _, _, _, _, _) => c }
@@ -301,8 +285,7 @@ tuple_impls! {
301
285
( n7, n7_ref) -> H { ( _, _, _, _, _, _, _, h, _) , ( _, _, _, _, _, _, _, ref h, _) => h }
302
286
( n8, n8_ref) -> I { ( _, _, _, _, _, _, _, _, i) , ( _, _, _, _, _, _, _, _, ref i) => i }
303
287
}
304
-
305
- ( Tuple10 , ImmutableTuple10 ) {
288
+ Tuple10 {
306
289
( n0, n0_ref) -> A { ( a, _, _, _, _, _, _, _, _, _) , ( ref a, _, _, _, _, _, _, _, _, _) => a }
307
290
( n1, n1_ref) -> B { ( _, b, _, _, _, _, _, _, _, _) , ( _, ref b, _, _, _, _, _, _, _, _) => b }
308
291
( n2, n2_ref) -> C { ( _, _, c, _, _, _, _, _, _, _) , ( _, _, ref c, _, _, _, _, _, _, _) => c }
@@ -314,8 +297,7 @@ tuple_impls! {
314
297
( n8, n8_ref) -> I { ( _, _, _, _, _, _, _, _, i, _) , ( _, _, _, _, _, _, _, _, ref i, _) => i }
315
298
( n9, n9_ref) -> J { ( _, _, _, _, _, _, _, _, _, j) , ( _, _, _, _, _, _, _, _, _, ref j) => j }
316
299
}
317
-
318
- ( Tuple11 , ImmutableTuple11 ) {
300
+ Tuple11 {
319
301
( n0, n0_ref) -> A { ( a, _, _, _, _, _, _, _, _, _, _) , ( ref a, _, _, _, _, _, _, _, _, _, _) => a }
320
302
( n1, n1_ref) -> B { ( _, b, _, _, _, _, _, _, _, _, _) , ( _, ref b, _, _, _, _, _, _, _, _, _) => b }
321
303
( n2, n2_ref) -> C { ( _, _, c, _, _, _, _, _, _, _, _) , ( _, _, ref c, _, _, _, _, _, _, _, _) => c }
@@ -328,8 +310,7 @@ tuple_impls! {
328
310
( n9, n9_ref) -> J { ( _, _, _, _, _, _, _, _, _, j, _) , ( _, _, _, _, _, _, _, _, _, ref j, _) => j }
329
311
( n10, n10_ref) -> K { ( _, _, _, _, _, _, _, _, _, _, k) , ( _, _, _, _, _, _, _, _, _, _, ref k) => k }
330
312
}
331
-
332
- ( Tuple12 , ImmutableTuple12 ) {
313
+ Tuple12 {
333
314
( n0, n0_ref) -> A { ( a, _, _, _, _, _, _, _, _, _, _, _) , ( ref a, _, _, _, _, _, _, _, _, _, _, _) => a }
334
315
( n1, n1_ref) -> B { ( _, b, _, _, _, _, _, _, _, _, _, _) , ( _, ref b, _, _, _, _, _, _, _, _, _, _) => b }
335
316
( n2, n2_ref) -> C { ( _, _, c, _, _, _, _, _, _, _, _, _) , ( _, _, ref c, _, _, _, _, _, _, _, _, _) => c }
0 commit comments