Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate futures; // 0.1.21
- use futures::Future;
- use futures::Stream;
- use futures::Poll;
- use futures::sync::mpsc::{unbounded, UnboundedSender, UnboundedReceiver};
- struct A {
- tx: UnboundedSender<i32>,
- }
- struct B {
- rx: UnboundedReceiver<i32>,
- }
- impl Future for B {
- type Item = i32;
- type Error = ();
- fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
- self.rx.poll().map(|a| a.map(|o| o.unwrap()))
- }
- }
- fn main() {
- let (tx, rx) = unbounded();
- let a = A { tx };
- let mut b = B { rx };
- b.poll();
- }
Add Comment
Please, Sign In to add comment