Skip to content

Commit

Permalink
Add BoxTryFuture and BoxTryStream aliases
Browse files Browse the repository at this point in the history
Including ones without `Send` bound like `LocalBoxTryFuture` and
`LocalBoxTryStream`.
  • Loading branch information
Velnbur committed Jul 12, 2024
1 parent c507ff8 commit b40684d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit b40684d

Please sign in to comment.