diff --git a/src/future/mod.rs b/src/future/mod.rs index 7e278bac88..2122296b35 100644 --- a/src/future/mod.rs +++ b/src/future/mod.rs @@ -308,7 +308,7 @@ pub trait Future { fn boxed(self) -> BoxFuture where Self: Sized + Send + 'static { - ::std::boxed::Box::new(self) + Boxed::boxed(self) } /// Map this future's result to a different type, returning a new future of @@ -1044,3 +1044,19 @@ impl fmt::Debug for ExecuteError { } } } + +trait Boxed: Future { + fn boxed(self) -> BoxFuture; +} + +impl Boxed for F where F: Future + Sized + Send + 'static { + default fn boxed(self) -> BoxFuture { + ::std::boxed::Box::new(self) + } +} + +impl Boxed for BoxFuture { + fn boxed(self) -> BoxFuture { + self + } +} diff --git a/src/lib.rs b/src/lib.rs index ed8c93f96d..7666173c41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -157,6 +157,7 @@ #![no_std] #![deny(missing_docs, missing_debug_implementations)] #![doc(html_root_url = "https://docs.rs/futures/0.1")] +#![feature(specialization)] #[macro_use] #[cfg(feature = "use_std")]