From 43ef5ad18410da5f50efc78fbb781f4e1037b02a Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Fri, 30 Aug 2013 20:00:26 +0200 Subject: [PATCH] std::select: Use correct indices from the front Caught a bug where .enumerate() was used on a reverse iterator. The indices should be counted from the front here (bblum confirms). --- src/libstd/select.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstd/select.rs b/src/libstd/select.rs index d0afeb4be85..9f4fd8db788 100644 --- a/src/libstd/select.rs +++ b/src/libstd/select.rs @@ -11,7 +11,7 @@ use cell::Cell; use comm; use container::Container; -use iterator::Iterator; +use iterator::{Iterator, DoubleEndedIterator}; use option::*; // use either::{Either, Left, Right}; // use rt::kill::BlockedTask; @@ -87,7 +87,7 @@ pub fn select(ports: &mut [A]) -> uint { // Task resumes. Now unblock ourselves from all the ports we blocked on. // If the success index wasn't reset, 'take' will just take all of them. // Iterate in reverse so the 'earliest' index that's ready gets returned. - for (index, port) in ports.mut_slice(0, ready_index).mut_rev_iter().enumerate() { + for (index, port) in ports.mut_slice(0, ready_index).mut_iter().enumerate().invert() { if port.unblock_from() { ready_index = index; }