diff options
author | Zahari Dichev <zaharidichev@gmail.com> | 2019-01-24 21:50:34 +0200 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2019-01-24 11:50:34 -0800 |
commit | fbad6297c5dc22a716a13c29433d89e2c75d7695 (patch) | |
tree | 5126773f1ebd16e463f826ae16fb564ee4220e89 /tokio-timer | |
parent | 0ec8986b0bc60cc96e88ab72e4675d975fbc8f1c (diff) |
Add enumerate combinator to Stream (#832)
Diffstat (limited to 'tokio-timer')
-rw-r--r-- | tokio-timer/tests/enumerate.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tokio-timer/tests/enumerate.rs b/tokio-timer/tests/enumerate.rs new file mode 100644 index 00000000..3e7ec125 --- /dev/null +++ b/tokio-timer/tests/enumerate.rs @@ -0,0 +1,31 @@ +extern crate futures; +extern crate tokio; +extern crate tokio_executor; +extern crate tokio_timer; + +#[macro_use] +mod support; + +use futures::prelude::*; +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 mut result = rx.enumerate().collect(); + assert_eq!( + result.wait(), + Ok(vec![(0, 0), (1, 2), (2, 4), (3, 6), (4, 8)]) + ); + +} |