Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove IntoFuture in trait bounds
  • Loading branch information
Harry Barber committed Jul 19, 2023
commit 60bcaed15e76c7a1b585cb4b39ae0a5fc671a6e7
24 changes: 12 additions & 12 deletions futures-util/src/future/try_future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ delegate_all!(
delegate_all!(
/// Future for the [`inspect_ok`](super::TryFutureExt::inspect_ok) method.
InspectOk<Fut, F>(
Inspect<IntoFuture<Fut>, InspectOkFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(IntoFuture::new(x), inspect_ok_fn(f))]
Inspect<Fut, InspectOkFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(x, inspect_ok_fn(f))]
);

delegate_all!(
/// Future for the [`inspect_err`](super::TryFutureExt::inspect_err) method.
InspectErr<Fut, F>(
Inspect<IntoFuture<Fut>, InspectErrFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(IntoFuture::new(x), inspect_err_fn(f))]
Inspect<Fut, InspectErrFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Inspect::new(x, inspect_err_fn(f))]
);

#[allow(unreachable_pub)] // https://github.com/rust-lang/rust/issues/57411
Expand All @@ -106,29 +106,29 @@ pub use self::into_future::IntoFuture;
delegate_all!(
/// Future for the [`map_ok`](TryFutureExt::map_ok) method.
MapOk<Fut, F>(
Map<IntoFuture<Fut>, MapOkFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(IntoFuture::new(x), map_ok_fn(f))]
Map<Fut, MapOkFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(x, map_ok_fn(f))]
);

delegate_all!(
/// Future for the [`map_err`](TryFutureExt::map_err) method.
MapErr<Fut, F>(
Map<IntoFuture<Fut>, MapErrFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(IntoFuture::new(x), map_err_fn(f))]
Map<Fut, MapErrFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(x, map_err_fn(f))]
);

delegate_all!(
/// Future for the [`map_ok_or_else`](TryFutureExt::map_ok_or_else) method.
MapOkOrElse<Fut, F, G>(
Map<IntoFuture<Fut>, MapOkOrElseFn<F, G>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F, g: G| Map::new(IntoFuture::new(x), map_ok_or_else_fn(f, g))]
Map<Fut, MapOkOrElseFn<F, G>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F, g: G| Map::new(x, map_ok_or_else_fn(f, g))]
);

delegate_all!(
/// Future for the [`unwrap_or_else`](TryFutureExt::unwrap_or_else) method.
UnwrapOrElse<Fut, F>(
Map<IntoFuture<Fut>, UnwrapOrElseFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(IntoFuture::new(x), unwrap_or_else_fn(f))]
Map<Fut, UnwrapOrElseFn<F>>
): Debug + Future + FusedFuture + New[|x: Fut, f: F| Map::new(x, unwrap_or_else_fn(f))]
);

impl<Fut: ?Sized + TryFuture> TryFutureExt for Fut {}
Expand Down
9 changes: 4 additions & 5 deletions futures-util/src/future/try_join_all.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ use core::mem;
use core::pin::Pin;
use core::task::{Context, Poll};

use super::{assert_future, join_all, IntoFuture, TryFuture, TryMaybeDone};
use super::{assert_future, join_all, TryFuture, TryMaybeDone};

#[cfg(not(futures_no_atomic_cas))]
use crate::stream::{FuturesOrdered, TryCollect, TryStreamExt};
use crate::TryFutureExt;

enum FinalState<E = ()> {
Pending,
Expand All @@ -36,11 +35,11 @@ where
F: TryFuture,
{
Small {
elems: Pin<Box<[TryMaybeDone<IntoFuture<F>>]>>,
elems: Pin<Box<[TryMaybeDone<F>]>>,
},
#[cfg(not(futures_no_atomic_cas))]
Big {
fut: TryCollect<FuturesOrdered<IntoFuture<F>>, Vec<F::Ok>>,
fut: TryCollect<FuturesOrdered<F>, Vec<F::Ok>>,
},
}

Expand Down Expand Up @@ -119,7 +118,7 @@ where
I: IntoIterator,
I::Item: TryFuture,
{
let iter = iter.into_iter().map(TryFutureExt::into_future);
let iter = iter.into_iter();

#[cfg(futures_no_atomic_cas)]
{
Expand Down
5 changes: 2 additions & 3 deletions futures-util/src/stream/try_stream/try_buffer_unordered.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::future::{IntoFuture, TryFutureExt};
use crate::stream::{Fuse, FuturesUnordered, IntoStream, StreamExt};
use core::num::NonZeroUsize;
use core::pin::Pin;
Expand All @@ -19,7 +18,7 @@ pin_project! {
{
#[pin]
stream: Fuse<IntoStream<St>>,
in_progress_queue: FuturesUnordered<IntoFuture<St::Ok>>,
in_progress_queue: FuturesUnordered<St::Ok>,
max: Option<NonZeroUsize>,
}
}
Expand Down Expand Up @@ -54,7 +53,7 @@ where
// our queue of futures. Propagate errors from the stream immediately.
while this.max.map(|max| this.in_progress_queue.len() < max.get()).unwrap_or(true) {
match this.stream.as_mut().poll_next(cx)? {
Poll::Ready(Some(fut)) => this.in_progress_queue.push(fut.into_future()),
Poll::Ready(Some(fut)) => this.in_progress_queue.push(fut),
Poll::Ready(None) | Poll::Pending => break,
}
}
Expand Down
5 changes: 2 additions & 3 deletions futures-util/src/stream/try_stream/try_buffered.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::future::{IntoFuture, TryFutureExt};
use crate::stream::{Fuse, FuturesOrdered, IntoStream, StreamExt};
use core::num::NonZeroUsize;
use core::pin::Pin;
Expand All @@ -20,7 +19,7 @@ pin_project! {
{
#[pin]
stream: Fuse<IntoStream<St>>,
in_progress_queue: FuturesOrdered<IntoFuture<St::Ok>>,
in_progress_queue: FuturesOrdered<St::Ok>,
max: Option<NonZeroUsize>,
}
}
Expand Down Expand Up @@ -55,7 +54,7 @@ where
// our queue of futures. Propagate errors from the stream immediately.
while this.max.map(|max| this.in_progress_queue.len() < max.get()).unwrap_or(true) {
match this.stream.as_mut().poll_next(cx)? {
Poll::Ready(Some(fut)) => this.in_progress_queue.push_back(fut.into_future()),
Poll::Ready(Some(fut)) => this.in_progress_queue.push_back(fut),
Poll::Ready(None) | Poll::Pending => break,
}
}
Expand Down