1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use futures::Future;
pub type BoxFuture<Item, Error> = Box<Future<Item = Item, Error = Error>>;
pub trait FutureExt: Future + Sized {
fn into_box(self) -> Box<Future<Item = Self::Item, Error = Self::Error>>;
}
impl<T: Future + 'static> FutureExt for T {
fn into_box(self) -> Box<Future<Item = Self::Item, Error = Self::Error>> {
Box::new(self)
}
}
pub mod boxfuture {
use futures::future;
use futures::future::FutureResult;
pub fn ok<T, E>(t: T) -> Box<FutureResult<T, E>> {
Box::new(future::ok(t))
}
}