@@ -11,36 +11,37 @@ use crate::marker::{StructuralEq, StructuralPartialEq};
11
11
// will implement everything for (A, B, C), (A, B) and (A,).
12
12
macro_rules! tuple_impls {
13
13
// Stopping criteria (1-ary tuple)
14
- ( $T: ident) => {
15
- tuple_impls!( @impl $T) ;
14
+ ( $T: ident $U : ident ) => {
15
+ tuple_impls!( @impl $T $U ) ;
16
16
} ;
17
17
// Running criteria (n-ary tuple, with n >= 2)
18
- ( $T: ident $( $U : ident ) +) => {
19
- tuple_impls!( $( $U ) +) ;
20
- tuple_impls!( @impl $T $( $U ) +) ;
18
+ ( $T: ident $U : ident $ ( $rest : ident ) +) => {
19
+ tuple_impls!( $( $rest ) +) ;
20
+ tuple_impls!( @impl $T $U $ ( $rest ) +) ;
21
21
} ;
22
22
// "Private" internal implementation
23
- ( @impl $( $T: ident ) +) => {
23
+ ( @impl $( $T: ident $U : ident ) +) => {
24
24
maybe_tuple_doc! {
25
- $( $T) + @
25
+ $( $T $U ) + @
26
26
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
27
- impl <$( $T: PartialEq ) , +> PartialEq for ( $( $T, ) +)
27
+ impl <$( $T: PartialEq <$U> , ) + $ ( $U , ) +> PartialEq < ( $ ( $U , ) + ) > for ( $( $T, ) +)
28
28
where
29
- last_type!( $( $T, ) +) : ?Sized
29
+ last_type!( $( $T, ) +) : ?Sized ,
30
+ last_type!( $( $U, ) +) : ?Sized
30
31
{
31
32
#[ inline]
32
- fn eq( & self , other: & ( $( $T , ) +) ) -> bool {
33
+ fn eq( & self , other: & ( $( $U , ) +) ) -> bool {
33
34
$( ${ ignore( T ) } self . ${ index( ) } == other. ${ index( ) } ) &&+
34
35
}
35
36
#[ inline]
36
- fn ne( & self , other: & ( $( $T , ) +) ) -> bool {
37
+ fn ne( & self , other: & ( $( $U , ) +) ) -> bool {
37
38
$( ${ ignore( T ) } self . ${ index( ) } != other. ${ index( ) } ) ||+
38
39
}
39
40
}
40
41
}
41
42
42
43
maybe_tuple_doc! {
43
- $( $T) + @
44
+ $( $T $U ) + @
44
45
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
45
46
impl <$( $T: Eq ) ,+> Eq for ( $( $T, ) +)
46
47
where
@@ -49,73 +50,74 @@ macro_rules! tuple_impls {
49
50
}
50
51
51
52
maybe_tuple_doc! {
52
- $( $T) + @
53
+ $( $T $U ) + @
53
54
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
54
55
#[ cfg( not( bootstrap) ) ]
55
56
impl <$( $T: ConstParamTy ) ,+> ConstParamTy for ( $( $T, ) +)
56
57
{ }
57
58
}
58
59
59
60
maybe_tuple_doc! {
60
- $( $T) + @
61
+ $( $T $U ) + @
61
62
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
62
63
impl <$( $T) ,+> StructuralPartialEq for ( $( $T, ) +)
63
64
{ }
64
65
}
65
66
66
67
maybe_tuple_doc! {
67
- $( $T) + @
68
+ $( $T $U ) + @
68
69
#[ unstable( feature = "structural_match" , issue = "31434" ) ]
69
70
impl <$( $T) ,+> StructuralEq for ( $( $T, ) +)
70
71
{ }
71
72
}
72
73
73
74
maybe_tuple_doc! {
74
- $( $T) + @
75
+ $( $T $U ) + @
75
76
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
76
- impl <$( $T: PartialOrd ) , +> PartialOrd for ( $( $T, ) +)
77
+ impl <$( $T: PartialOrd <$U> , ) + $ ( $U , ) +> PartialOrd < ( $ ( $U , ) + ) > for ( $( $T, ) +)
77
78
where
78
- last_type!( $( $T, ) +) : ?Sized
79
+ last_type!( $( $T, ) +) : ?Sized ,
80
+ last_type!( $( $U, ) +) : ?Sized
79
81
{
80
82
#[ inline]
81
- fn partial_cmp( & self , other: & ( $( $T , ) +) ) -> Option <Ordering > {
83
+ fn partial_cmp( & self , other: & ( $( $U , ) +) ) -> Option <Ordering > {
82
84
lexical_partial_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
83
85
}
84
86
#[ inline]
85
- fn lt( & self , other: & ( $( $T , ) +) ) -> bool {
87
+ fn lt( & self , other: & ( $( $U , ) +) ) -> bool {
86
88
lexical_ord!( lt, Less , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
87
89
}
88
90
#[ inline]
89
- fn le( & self , other: & ( $( $T , ) +) ) -> bool {
91
+ fn le( & self , other: & ( $( $U , ) +) ) -> bool {
90
92
lexical_ord!( le, Less , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
91
93
}
92
94
#[ inline]
93
- fn ge( & self , other: & ( $( $T , ) +) ) -> bool {
95
+ fn ge( & self , other: & ( $( $U , ) +) ) -> bool {
94
96
lexical_ord!( ge, Greater , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
95
97
}
96
98
#[ inline]
97
- fn gt( & self , other: & ( $( $T , ) +) ) -> bool {
99
+ fn gt( & self , other: & ( $( $U , ) +) ) -> bool {
98
100
lexical_ord!( gt, Greater , $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
99
101
}
100
102
}
101
103
}
102
104
103
105
maybe_tuple_doc! {
104
- $( $T) + @
106
+ $( $T $U ) + @
105
107
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
106
108
impl <$( $T: Ord ) ,+> Ord for ( $( $T, ) +)
107
109
where
108
110
last_type!( $( $T, ) +) : ?Sized
109
111
{
110
112
#[ inline]
111
- fn cmp( & self , other: & ( $ ( $T , ) + ) ) -> Ordering {
113
+ fn cmp( & self , other: & Self ) -> Ordering {
112
114
lexical_cmp!( $( ${ ignore( T ) } self . ${ index( ) } , other. ${ index( ) } ) ,+)
113
115
}
114
116
}
115
117
}
116
118
117
119
maybe_tuple_doc! {
118
- $( $T) + @
120
+ $( $T $U ) + @
119
121
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
120
122
impl <$( $T: Default ) ,+> Default for ( $( $T, ) +) {
121
123
#[ inline]
@@ -219,4 +221,4 @@ macro_rules! last_type {
219
221
( $a: ident, $( $rest_a: ident, ) +) => { last_type!( $( $rest_a, ) +) } ;
220
222
}
221
223
222
- tuple_impls ! ( E D C B A Z Y X W V U T ) ;
224
+ tuple_impls ! ( E1 E2 D1 D2 C1 C2 B1 B2 A1 A2 Z1 Z2 Y1 Y2 X1 X2 W1 W2 V1 V2 U1 U2 T1 T2 ) ;
0 commit comments