From 8bdb4ef4d584031edc0327cd01158254e4d0d122 Mon Sep 17 00:00:00 2001 From: Josef Reinhard Brandl Date: Thu, 2 Aug 2018 22:06:41 +0200 Subject: [PATCH] Rename NeverError To UnitError --- futures-util/src/compat/executor.rs | 6 +++--- futures-util/src/future/mod.rs | 10 +++++----- .../future/{never_error.rs => unit_error.rs} | 18 +++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) rename futures-util/src/future/{never_error.rs => unit_error.rs} (52%) diff --git a/futures-util/src/compat/executor.rs b/futures-util/src/compat/executor.rs index 0933ffade8..377d7be96b 100644 --- a/futures-util/src/compat/executor.rs +++ b/futures-util/src/compat/executor.rs @@ -1,6 +1,6 @@ use super::Compat; -use crate::{TryFutureExt, FutureExt, future::NeverError}; +use crate::{TryFutureExt, FutureExt, future::UnitError}; use futures::future::Executor as Executor01; use futures_core::task::Executor as Executor03; use futures_core::task as task03; @@ -18,7 +18,7 @@ impl Executor03 for BoxedExecutor03 { } /// A future that can run on a futures 0.1 executor. -pub type Executor01Future = Compat>, BoxedExecutor03>; +pub type Executor01Future = Compat>, BoxedExecutor03>; /// Extension trait for futures 0.1 Executors. pub trait Executor01CompatExt: Executor01 + @@ -53,7 +53,7 @@ where Ex: Executor01, &mut self, future: FutureObj<'static, ()>, ) -> Result<(), task03::SpawnObjError> { - let future = future.never_error().compat(BoxedExecutor03(Box::new(self.clone()))); + let future = future.unit_error().compat(BoxedExecutor03(Box::new(self.clone()))); match self.executor01.execute(future) { Ok(()) => Ok(()), diff --git a/futures-util/src/future/mod.rs b/futures-util/src/future/mod.rs index 86fb5debe6..1ba7279673 100644 --- a/futures-util/src/future/mod.rs +++ b/futures-util/src/future/mod.rs @@ -57,8 +57,8 @@ pub use self::then::Then; mod inspect; pub use self::inspect::Inspect; -mod never_error; -pub use self::never_error::NeverError; +mod unit_error; +pub use self::unit_error::UnitError; mod with_executor; pub use self::with_executor::WithExecutor; @@ -645,11 +645,11 @@ pub trait FutureExt: Future { PinBox::new(self) } - /// Turns a `Future` into a `TryFuture` that never errors - fn never_error(self) -> NeverError + /// Turns a `Future` into a `TryFuture` with `Error = ()`. + fn unit_error(self) -> UnitError where Self: Sized { - NeverError::new(self) + UnitError::new(self) } /// Assigns the provided `Executor` to be used when spawning tasks diff --git a/futures-util/src/future/never_error.rs b/futures-util/src/future/unit_error.rs similarity index 52% rename from futures-util/src/future/never_error.rs rename to futures-util/src/future/unit_error.rs index 13866ffbce..608a044ac9 100644 --- a/futures-util/src/future/never_error.rs +++ b/futures-util/src/future/unit_error.rs @@ -3,27 +3,27 @@ use core::mem::PinMut; use futures_core::future::Future; use futures_core::task::{self, Poll}; -/// Future for the `never_error` combinator, turning a `Future` into a `TryFuture`. +/// Future for the `unit_error` combinator, turning a `Future` into a `TryFuture`. /// -/// This is created by the `FutureExt::never_error` method. +/// This is created by the `FutureExt::unit_error` method. #[derive(Debug)] #[must_use = "futures do nothing unless polled"] -pub struct NeverError { +pub struct UnitError { future: Fut, } -impl NeverError { +impl UnitError { unsafe_pinned!(future: Fut); - /// Creates a new NeverError. - pub(super) fn new(future: Fut) -> NeverError { - NeverError { future } + /// Creates a new UnitError. + pub(super) fn new(future: Fut) -> UnitError { + UnitError { future } } } -impl Unpin for NeverError {} +impl Unpin for UnitError {} -impl Future for NeverError +impl Future for UnitError where Fut: Future, { type Output = Result;