Skip to content

Commit

Permalink
Rename NeverError To UnitError
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorBreakfast committed Aug 2, 2018
1 parent e711c1a commit 8bdb4ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions futures-util/src/compat/executor.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +18,7 @@ impl Executor03 for BoxedExecutor03 {
}

/// A future that can run on a futures 0.1 executor.
pub type Executor01Future = Compat<NeverError<FutureObj<'static, ()>>, BoxedExecutor03>;
pub type Executor01Future = Compat<UnitError<FutureObj<'static, ()>>, BoxedExecutor03>;

/// Extension trait for futures 0.1 Executors.
pub trait Executor01CompatExt: Executor01<Executor01Future> +
Expand Down Expand Up @@ -53,7 +53,7 @@ where Ex: Executor01<Executor01Future>,
&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(()),
Expand Down
10 changes: 5 additions & 5 deletions futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Self>
/// Turns a `Future` into a `TryFuture` with `Error = ()`.
fn unit_error(self) -> UnitError<Self>
where Self: Sized
{
NeverError::new(self)
UnitError::new(self)
}

/// Assigns the provided `Executor` to be used when spawning tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Fut> {
pub struct UnitError<Fut> {
future: Fut,
}

impl<Fut> NeverError<Fut> {
impl<Fut> UnitError<Fut> {
unsafe_pinned!(future: Fut);

/// Creates a new NeverError.
pub(super) fn new(future: Fut) -> NeverError<Fut> {
NeverError { future }
/// Creates a new UnitError.
pub(super) fn new(future: Fut) -> UnitError<Fut> {
UnitError { future }
}
}

impl<Fut: Unpin> Unpin for NeverError<Fut> {}
impl<Fut: Unpin> Unpin for UnitError<Fut> {}

impl<Fut, T> Future for NeverError<Fut>
impl<Fut, T> Future for UnitError<Fut>
where Fut: Future<Output = T>,
{
type Output = Result<T, ()>;
Expand Down

0 comments on commit 8bdb4ef

Please sign in to comment.