Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BoxTryFuture and BoxTryStream aliases #2870

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions futures-core/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ pub type BoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + Send
#[cfg(feature = "alloc")]
pub type LocalBoxFuture<'a, T> = Pin<alloc::boxed::Box<dyn Future<Output = T> + 'a>>;

/// [`BoxFuture`] with [`TryFuture`] instead.
#[cfg(feature = "alloc")]
pub type BoxTryFuture<'a, T, E> =
Pin<alloc::boxed::Box<dyn TryFuture<Ok = T, Error = E, Output = Result<T, E>> + Send + 'a>>;

/// [`BoxTryFuture`], but without the `Send` requirement.
#[cfg(feature = "alloc")]
pub type LocalBoxTryFuture<'a, T, E> =
Pin<alloc::boxed::Box<dyn TryFuture<Ok = T, Error = E, Output = Result<T, E>> + 'a>>;

/// A future which tracks whether or not the underlying future
/// should no longer be polled.
///
Expand Down
10 changes: 10 additions & 0 deletions futures-core/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ pub type BoxStream<'a, T> = Pin<alloc::boxed::Box<dyn Stream<Item = T> + Send +
#[cfg(feature = "alloc")]
pub type LocalBoxStream<'a, T> = Pin<alloc::boxed::Box<dyn Stream<Item = T> + 'a>>;

/// [`BoxStream`] with [`TryStream`].
#[cfg(feature = "alloc")]
pub type BoxTryStream<'a, T, E> =
Pin<alloc::boxed::Box<dyn TryStream<Item = Result<T, E>, Ok = T, Error = E> + Send + 'a>>;

/// [`BoxTryStream`], but without the `Send` requirement.
#[cfg(feature = "alloc")]
pub type LocalBoxTryStream<'a, T, E> =
Pin<alloc::boxed::Box<dyn TryStream<Item = Result<T, E>, Ok = T, Error = E> + 'a>>;

/// A stream of values produced asynchronously.
///
/// If `Future<Output = T>` is an asynchronous version of `T`, then `Stream<Item
Expand Down
Loading