Skip to content

Commit eac1d63

Browse files
committed
Trying to generalize tuple PartialEq & PartialOrd impls
1 parent 41f2b6b commit eac1d63

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

library/core/src/tuple.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ macro_rules! tuple_impls {
2323
maybe_tuple_doc! {
2424
$($T)+ @
2525
#[stable(feature = "rust1", since = "1.0.0")]
26-
impl<$($T: PartialEq),+> PartialEq for ($($T,)+) {
26+
impl<$(${concat($T, _)}, $T: PartialEq<${concat($T, _)}>),+> PartialEq<($(${concat($T, _)},)+)> for ($($T,)+) {
2727
#[inline]
28-
fn eq(&self, other: &($($T,)+)) -> bool {
28+
fn eq(&self, other: &($(${concat($T, _)},)+)) -> bool {
2929
$( ${ignore($T)} self.${index()} == other.${index()} )&&+
3030
}
3131
#[inline]
32-
fn ne(&self, other: &($($T,)+)) -> bool {
32+
fn ne(&self, other: &($(${concat($T, _)},)+)) -> bool {
3333
$( ${ignore($T)} self.${index()} != other.${index()} )||+
3434
}
3535
}
@@ -66,42 +66,42 @@ macro_rules! tuple_impls {
6666
maybe_tuple_doc! {
6767
$($T)+ @
6868
#[stable(feature = "rust1", since = "1.0.0")]
69-
impl<$($T: PartialOrd),+> PartialOrd for ($($T,)+)
69+
impl<$(${concat($T, _)}, $T: PartialOrd<${concat($T, _)}>),+> PartialOrd<($(${concat($T, _)},)+)> for ($($T,)+)
7070
{
7171
#[inline]
72-
fn partial_cmp(&self, other: &($($T,)+)) -> Option<Ordering> {
72+
fn partial_cmp(&self, other: &($(${concat($T, _)},)+)) -> Option<Ordering> {
7373
lexical_partial_cmp!($( ${ignore($T)} self.${index()}, other.${index()} ),+)
7474
}
7575
#[inline]
76-
fn lt(&self, other: &($($T,)+)) -> bool {
76+
fn lt(&self, other: &($(${concat($T, _)},)+)) -> bool {
7777
lexical_ord!(lt, __chaining_lt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
7878
}
7979
#[inline]
80-
fn le(&self, other: &($($T,)+)) -> bool {
80+
fn le(&self, other: &($(${concat($T, _)},)+)) -> bool {
8181
lexical_ord!(le, __chaining_le, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
8282
}
8383
#[inline]
84-
fn ge(&self, other: &($($T,)+)) -> bool {
84+
fn ge(&self, other: &($(${concat($T, _)},)+)) -> bool {
8585
lexical_ord!(ge, __chaining_ge, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
8686
}
8787
#[inline]
88-
fn gt(&self, other: &($($T,)+)) -> bool {
88+
fn gt(&self, other: &($(${concat($T, _)},)+)) -> bool {
8989
lexical_ord!(gt, __chaining_gt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
9090
}
9191
#[inline]
92-
fn __chaining_lt(&self, other: &($($T,)+)) -> ControlFlow<bool> {
92+
fn __chaining_lt(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
9393
lexical_chain!(__chaining_lt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
9494
}
9595
#[inline]
96-
fn __chaining_le(&self, other: &($($T,)+)) -> ControlFlow<bool> {
96+
fn __chaining_le(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
9797
lexical_chain!(__chaining_le, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
9898
}
9999
#[inline]
100-
fn __chaining_gt(&self, other: &($($T,)+)) -> ControlFlow<bool> {
100+
fn __chaining_gt(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
101101
lexical_chain!(__chaining_gt, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
102102
}
103103
#[inline]
104-
fn __chaining_ge(&self, other: &($($T,)+)) -> ControlFlow<bool> {
104+
fn __chaining_ge(&self, other: &($(${concat($T, _)},)+)) -> ControlFlow<bool> {
105105
lexical_chain!(__chaining_ge, $( ${ignore($T)} self.${index()}, other.${index()} ),+)
106106
}
107107
}

0 commit comments

Comments
 (0)