Switch over to new range_rev semantics; fix #5270.

This commit is contained in:
Felix S. Klock II 2013-07-01 12:30:14 +02:00
parent 3c19f1bca8
commit db0a13b986
6 changed files with 21 additions and 19 deletions

View file

@ -132,9 +132,10 @@ pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
}
#[inline]
/// Iterate over the range [`hi`..`lo`)
/// Iterate over the range (`hi`..`lo`]
pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
range_step(hi, lo, -1 as $T, it)
if hi == min_value { return true; }
range_step_inclusive(hi-1, lo, -1 as $T, it)
}
impl Num for $T {}
@ -897,7 +898,7 @@ mod tests {
for range(0,3) |i| {
l.push(i);
}
for range_rev(13,10) |i| {
for range_rev(14,11) |i| {
l.push(i);
}
for range_step(20,26,2) |i| {

View file

@ -132,9 +132,10 @@ pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
}
#[inline]
/// Iterate over the range [`hi`..`lo`)
/// Iterate over the range (`hi`..`lo`]
pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
range_step(hi, lo, -1 as $T_SIGNED, it)
if hi == min_value { return true; }
range_step_inclusive(hi-1, lo, -1 as $T_SIGNED, it)
}
impl Num for $T {}
@ -662,7 +663,7 @@ mod tests {
for range(0,3) |i| {
l.push(i);
}
for range_rev(13,10) |i| {
for range_rev(14,11) |i| {
l.push(i);
}
for range_step(20,26,2) |i| {

View file

@ -669,7 +669,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
fail!("failure in dup3(err_fd, 2): %s", os::last_os_error());
}
// close all other fds
for int::range_rev(getdtablesize() as int - 1, 2) |fd| {
for int::range_rev(getdtablesize() as int, 3) |fd| {
close(fd as c_int);
}

View file

@ -261,7 +261,7 @@ impl<T> TrieNode<T> {
fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
for uint::range_rev(self.children.len(), 0) |idx| {
match self.children[idx - 1] {
match self.children[idx] {
Internal(ref x) => if !x.each_reverse(|i,t| f(i,t)) { return false },
External(k, ref v) => if !f(&k, v) { return false },
Nothing => ()