Skip to content

Commit 93f24f4

Browse files
committed
---
yaml --- r: 62478 b: refs/heads/snap-stage3 c: d9eec66 h: refs/heads/master v: v3
1 parent de4cc5c commit 93f24f4

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: db453ec0e507382b4ac1bb9eae4654957b8a7e76
4+
refs/heads/snap-stage3: d9eec664fd812dda88c349d092f327c9be8a7558
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/tuple.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ macro_rules! tuple_impls(
165165
fn eq(&self, other: &($($T),+)) -> bool {
166166
$(*self.$get_ref_fn() == *other.$get_ref_fn())&&+
167167
}
168-
169168
#[inline(always)]
170169
fn ne(&self, other: &($($T),+)) -> bool {
171170
!(*self == *other)
@@ -176,29 +175,30 @@ macro_rules! tuple_impls(
176175
impl<$($T:Ord),+> Ord for ($($T),+) {
177176
#[inline(always)]
178177
fn lt(&self, other: &($($T),+)) -> bool {
179-
$(*self.$get_ref_fn() < *other.$get_ref_fn())&&+
178+
lexical_lt!($(*self.$get_ref_fn(), *other.$get_ref_fn()),+)
180179
}
181-
182180
#[inline(always)]
183-
fn le(&self, other: &($($T),+)) -> bool {
184-
$(*self.$get_ref_fn() <= *other.$get_ref_fn())&&+
185-
}
186-
181+
fn le(&self, other: &($($T),+)) -> bool { !(*other).lt(&(*self)) }
187182
#[inline(always)]
188-
fn ge(&self, other: &($($T),+)) -> bool {
189-
$(*self.$get_ref_fn() >= *other.$get_ref_fn())&&+
190-
}
191-
183+
fn ge(&self, other: &($($T),+)) -> bool { !(*self).lt(other) }
192184
#[inline(always)]
193-
fn gt(&self, other: &($($T),+)) -> bool {
194-
$(*self.$get_ref_fn() > *other.$get_ref_fn())&&+
195-
}
185+
fn gt(&self, other: &($($T),+)) -> bool { (*other).lt(&(*self)) }
196186
}
197187
)+
198188
}
199189
)
200190
)
201191

192+
// Constructs an expression that performs a lexical less-than ordering.
193+
// The values are interleaved, so the macro invocation for
194+
// `(a1, a2, a3) < (b1, b2, b3)` would be `lexical_lt!(a1, b1, a2, b2, a3, b3)`
195+
macro_rules! lexical_lt(
196+
($a:expr, $b:expr, $($rest_a:expr, $rest_b:expr),+) => (
197+
if $a < $b { true } else { lexical_lt!($($rest_a, $rest_b),+) }
198+
);
199+
($a:expr, $b:expr) => ($a < $b);
200+
)
201+
202202
tuple_impls!(
203203
(CloneableTuple2, ImmutableTuple2) {
204204
(n0, n0_ref) -> A { (ref a,_) => a }

0 commit comments

Comments
 (0)