mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-26 00:00:16 +02:00
25 lines
476 B
Rust
25 lines
476 B
Rust
#![cfg(feature = "broken")]
|
|
#![deny(warnings, rust_2018_idioms)]
|
|
|
|
use futures::sync::mpsc;
|
|
use tokio::util::StreamExt;
|
|
|
|
#[test]
|
|
fn enumerate() {
|
|
use futures::*;
|
|
|
|
let (mut tx, rx) = mpsc::channel(1);
|
|
|
|
std::thread::spawn(|| {
|
|
for i in 0..5 {
|
|
tx = tx.send(i * 2).wait().unwrap();
|
|
}
|
|
});
|
|
|
|
let result = rx.enumerate().collect();
|
|
assert_eq!(
|
|
result.wait(),
|
|
Ok(vec![(0, 0), (1, 2), (2, 4), (3, 6), (4, 8)])
|
|
);
|
|
}
|