diff --git a/futures-util/src/compat/mod.rs b/futures-util/src/compat/mod.rs index 5b437e65ef..cb4dad6cb0 100644 --- a/futures-util/src/compat/mod.rs +++ b/futures-util/src/compat/mod.rs @@ -133,3 +133,16 @@ impl Wake for Current { arc_self.0.notify(); } } + +/// Extension trait for futures 0.1. +pub trait Future01Ext: Future01 { + /// Converts the future into a futures 0.3 future. + fn compat(self) -> Compat where Self: Sized { + Compat { + inner: self, + executor: None, + } + } +} + +impl Future01Ext for T {} \ No newline at end of file diff --git a/futures-util/src/future/mod.rs b/futures-util/src/future/mod.rs index c27822da62..86fb5debe6 100644 --- a/futures-util/src/future/mod.rs +++ b/futures-util/src/future/mod.rs @@ -68,6 +68,8 @@ mod chain; crate use self::chain::Chain; if_std! { + use std::boxed::PinBox; + mod abortable; pub use self::abortable::{abortable, Abortable, AbortHandle, AbortRegistration, Aborted}; @@ -86,8 +88,6 @@ if_std! { mod shared; pub use self::shared::Shared; - - use std::boxed::PinBox; } impl FutureExt for T where T: Future {} diff --git a/futures-util/src/future/never_error.rs b/futures-util/src/future/never_error.rs index 3de69abcf4..13866ffbce 100644 --- a/futures-util/src/future/never_error.rs +++ b/futures-util/src/future/never_error.rs @@ -29,11 +29,6 @@ impl Future for NeverError type Output = Result; fn poll(mut self: PinMut, cx: &mut task::Context) -> Poll> { - match self.future().poll(cx) { - Poll::Pending => Poll::Pending, - Poll::Ready(output) => { - Poll::Ready(Ok(output)) - } - } + self.future().poll(cx).map(Ok) } }