I am trying to write a simple exmaple of futures-rs mpsc queues usage:
extern crate futures; // v0.1 (old)
use futures::{Sink, Stream};
use futures::sync::mpsc;
use std::thread;
fn main() {
let (tx, rx) = mpsc::channel::<i32>(1000);
let handle = thread::spawn(move || {
tx.clone().send(1);
tx.clone().send(2);
tx.clone().send(3);
});
let mut rx = rx.map(|x| {
println!("stream: {}", x);
x * x
});
handle.join().unwrap();
rx.poll().unwrap();
}
But it doesn't output anything to the console (I expect it to print stream: 1
, stream: 2
and stream: 3
). I also tried to replace rx.poll().unwrap()
with rx.wait()
, but it still outputs nothing. And I didn't find any usage examples in the futures-rs docs. What am I doing wrong?