Skip to content

Commit

Permalink
Remove Never type alias
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Feb 13, 2021
1 parent f71d3f7 commit 683e77e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 37 deletions.
6 changes: 3 additions & 3 deletions futures-sink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ where
#[cfg(feature = "alloc")]
mod if_alloc {
use super::*;
use core::convert::Infallible as Never;
use core::convert::Infallible;

impl<T> Sink<T> for alloc::vec::Vec<T> {
type Error = Never;
type Error = Infallible;

fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
Expand All @@ -183,7 +183,7 @@ mod if_alloc {
}

impl<T> Sink<T> for alloc::collections::VecDeque<T> {
type Error = Never;
type Error = Infallible;

fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
Expand Down
6 changes: 3 additions & 3 deletions futures-util/src/future/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#[cfg(feature = "alloc")]
use alloc::boxed::Box;
use core::pin::Pin;
use core::convert::Infallible;

use crate::fns::{inspect_fn, into_fn, ok_fn, InspectFn, IntoFn, OkFn};
use crate::future::{assert_future, Either};
use crate::never::Never;
use crate::stream::assert_stream;
#[cfg(feature = "alloc")]
use futures_core::future::{BoxFuture, LocalBoxFuture};
Expand Down Expand Up @@ -83,7 +83,7 @@ delegate_all!(
delegate_all!(
/// Future for the [`never_error`](super::FutureExt::never_error) combinator.
NeverError<Fut>(
Map<Fut, OkFn<Never>>
Map<Fut, OkFn<Infallible>>
): Debug + Future + FusedFuture + New[|x: Fut| Map::new(x, ok_fn())]
);

Expand Down Expand Up @@ -551,7 +551,7 @@ pub trait FutureExt: Future {
where
Self: Sized,
{
assert_future::<Result<Self::Output, Never>, _>(NeverError::new(self))
assert_future::<Result<Self::Output, Infallible>, _>(NeverError::new(self))
}

/// A convenience for calling `Future::poll` on `Unpin` future types.
Expand Down
2 changes: 0 additions & 2 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@ pub use crate::sink::SinkExt;

pub mod task;

pub mod never;

#[cfg(feature = "compat")]
#[cfg_attr(docsrs, doc(cfg(feature = "compat")))]
pub mod compat;
Expand Down
18 changes: 0 additions & 18 deletions futures-util/src/never.rs

This file was deleted.

8 changes: 4 additions & 4 deletions futures-util/src/sink/drain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::assert_sink;
use crate::never::Never;
use core::convert::Infallible;
use core::marker::PhantomData;
use core::pin::Pin;
use futures_core::task::{Context, Poll};
Expand All @@ -24,16 +24,16 @@ pub struct Drain<T> {
///
/// let mut drain = sink::drain();
/// drain.send(5).await?;
/// # Ok::<(), futures::never::Never>(()) }).unwrap();
/// # Ok::<(), std::convert::Infallible>(()) }).unwrap();
/// ```
pub fn drain<T>() -> Drain<T> {
assert_sink::<T, Never, _>(Drain { marker: PhantomData })
assert_sink::<T, Infallible, _>(Drain { marker: PhantomData })
}

impl<T> Unpin for Drain<T> {}

impl<T> Sink<T> for Drain<T> {
type Error = Never;
type Error = Infallible;

fn poll_ready(
self: Pin<&mut Self>,
Expand Down
4 changes: 2 additions & 2 deletions futures-util/src/sink/unfold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ pin_project! {
/// async move {
/// sum += i;
/// eprintln!("{}", i);
/// Ok::<_, futures::never::Never>(sum)
/// Ok::<_, std::convert::Infallible>(sum)
/// }
/// });
/// futures::pin_mut!(unfold);
/// unfold.send(5).await?;
/// # Ok::<(), futures::never::Never>(()) }).unwrap();
/// # Ok::<(), std::convert::Infallible>(()) }).unwrap();
/// ```
pub fn unfold<T, F, R, Item, E>(init: T, function: F) -> Unfold<T, F, R>
where
Expand Down
2 changes: 1 addition & 1 deletion futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub use futures_util::{join, pending, poll, select_biased, try_join}; // Async-a

// Module reexports
#[doc(inline)]
pub use futures_util::{future, never, sink, stream, task};
pub use futures_util::{future, sink, stream, task};

#[cfg(feature = "alloc")]
#[doc(inline)]
Expand Down
8 changes: 4 additions & 4 deletions futures/tests/sink.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::convert::Infallible;

mod sassert_next {
use futures::stream::{Stream, StreamExt};
use futures::task::Poll;
Expand Down Expand Up @@ -356,7 +358,6 @@ fn with_flush() {
use futures::channel::oneshot;
use futures::executor::block_on;
use futures::future::{self, FutureExt, TryFutureExt};
use futures::never::Never;
use futures::sink::{Sink, SinkExt};
use std::mem;
use std::pin::Pin;
Expand All @@ -369,7 +370,7 @@ fn with_flush() {
let mut sink = Vec::new().with(|elem| {
mem::replace(&mut block, future::ok(()).boxed())
.map_ok(move |()| elem + 1)
.map_err(|_| -> Never { panic!() })
.map_err(|_| -> Infallible { panic!() })
});

assert_eq!(Pin::new(&mut sink).start_send(0).ok(), Some(()));
Expand All @@ -392,10 +393,9 @@ fn with_flush() {
fn with_as_map() {
use futures::executor::block_on;
use futures::future;
use futures::never::Never;
use futures::sink::SinkExt;

let mut sink = Vec::new().with(|item| future::ok::<i32, Never>(item * 2));
let mut sink = Vec::new().with(|item| future::ok::<i32, Infallible>(item * 2));
block_on(sink.send(0)).unwrap();
block_on(sink.send(1)).unwrap();
block_on(sink.send(2)).unwrap();
Expand Down

0 comments on commit 683e77e

Please sign in to comment.