Skip to content

Commit 43ef5ad

Browse files
author
blake2-ppc
committed
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).
1 parent 46a6dbc commit 43ef5ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/libstd/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use cell::Cell;
1212
use comm;
1313
use container::Container;
14-
use iterator::Iterator;
14+
use iterator::{Iterator, DoubleEndedIterator};
1515
use option::*;
1616
// use either::{Either, Left, Right};
1717
// use rt::kill::BlockedTask;
@@ -87,7 +87,7 @@ pub fn select<A: Select>(ports: &mut [A]) -> uint {
8787
// Task resumes. Now unblock ourselves from all the ports we blocked on.
8888
// If the success index wasn't reset, 'take' will just take all of them.
8989
// Iterate in reverse so the 'earliest' index that's ready gets returned.
90-
for (index, port) in ports.mut_slice(0, ready_index).mut_rev_iter().enumerate() {
90+
for (index, port) in ports.mut_slice(0, ready_index).mut_iter().enumerate().invert() {
9191
if port.unblock_from() {
9292
ready_index = index;
9393
}

0 commit comments

Comments
 (0)