1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use futures::Future; pub trait Future2 { type Item; type Error; } /// A type alias for Box<Item = T, Error = E> pub type BoxFuture<T, E> = Box<Future<Item = T, Error = E>>; pub trait FutureExt: Future { fn into_box(self) -> BoxFuture<Self::Item, Self::Error> where Self: Sized + 'static, { Box::new(self) } } impl<F: Future> FutureExt for F {}