From b40684d0a7a9a38f72677396cf763d45c6b23fa8 Mon Sep 17 00:00:00 2001 From: Velnbur Date: Fri, 12 Jul 2024 16:55:06 +0300 Subject: [PATCH] Add `BoxTryFuture` and `BoxTryStream` aliases Including ones without `Send` bound like `LocalBoxTryFuture` and `LocalBoxTryStream`. --- futures-core/src/future.rs | 10 ++++++++++ futures-core/src/stream.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/futures-core/src/future.rs b/futures-core/src/future.rs index 7540cd027e..6c60216fde 100644 --- a/futures-core/src/future.rs +++ b/futures-core/src/future.rs @@ -16,6 +16,16 @@ pub type BoxFuture<'a, T> = Pin + Send #[cfg(feature = "alloc")] pub type LocalBoxFuture<'a, T> = Pin + 'a>>; +/// [`BoxFuture`] with [`TryFuture`] instead. +#[cfg(feature = "alloc")] +pub type BoxTryFuture<'a, T, E> = + Pin> + Send + 'a>>; + +/// [`BoxTryFuture`], but without the `Send` requirement. +#[cfg(feature = "alloc")] +pub type LocalBoxTryFuture<'a, T, E> = + Pin> + 'a>>; + /// A future which tracks whether or not the underlying future /// should no longer be polled. /// diff --git a/futures-core/src/stream.rs b/futures-core/src/stream.rs index ad5350b795..921cccad15 100644 --- a/futures-core/src/stream.rs +++ b/futures-core/src/stream.rs @@ -13,6 +13,16 @@ pub type BoxStream<'a, T> = Pin + Send + #[cfg(feature = "alloc")] pub type LocalBoxStream<'a, T> = Pin + 'a>>; +/// [`BoxStream`] with [`TryStream`]. +#[cfg(feature = "alloc")] +pub type BoxTryStream<'a, T, E> = + Pin, Ok = T, Error = E> + Send + 'a>>; + +/// [`BoxTryStream`], but without the `Send` requirement. +#[cfg(feature = "alloc")] +pub type LocalBoxTryStream<'a, T, E> = + Pin, Ok = T, Error = E> + 'a>>; + /// A stream of values produced asynchronously. /// /// If `Future` is an asynchronous version of `T`, then `Stream