Skip to content

Commit c8f4866

Browse files
committed
Correct bench
1 parent b59da8a commit c8f4866

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

futures-util/benches/flatten_unordered.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use futures::executor::block_on;
88
use futures::future;
99
use futures::stream::{self, StreamExt};
1010
use futures::task::Poll;
11+
use futures_util::FutureExt;
1112
use std::collections::VecDeque;
1213
use std::thread;
1314

@@ -34,17 +35,9 @@ fn oneshot_streams(b: &mut Bencher) {
3435
}
3536
});
3637

37-
let mut flatten = stream::unfold(rxs.into_iter(), |mut vals| {
38-
Box::pin(async {
39-
if let Some(next) = vals.next() {
40-
let val = next.await.unwrap();
41-
Some((val, vals))
42-
} else {
43-
None
44-
}
45-
})
46-
})
47-
.flatten_unordered(None);
38+
let mut flatten = stream::iter(rxs)
39+
.map(|recv| recv.into_stream().map(|val| val.unwrap()).flatten())
40+
.flatten_unordered(None);
4841

4942
block_on(future::poll_fn(move |cx| {
5043
let mut count = 0;

0 commit comments

Comments
 (0)