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

Fix Unpin impl of (Try)MaybeDone #2317

Merged
merged 1 commit into from
Jan 14, 2021
Merged
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
4 changes: 2 additions & 2 deletions futures-util/src/future/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use futures_sink::Sink;
#[derive(Debug, Clone)]
pub enum Either<A, B> {
/// First branch of the type
Left(A),
Left(/* #[pin] */ A),
/// Second branch of the type
Right(B),
Right(/* #[pin] */ B),
}

impl<A, B> Either<A, B> {
Expand Down
4 changes: 3 additions & 1 deletion futures-util/src/future/maybe_done.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ use futures_core::task::{Context, Poll};
#[derive(Debug)]
pub enum MaybeDone<Fut: Future> {
/// A not-yet-completed future
Future(Fut),
Future(/* #[pin] */ Fut),
/// The output of the completed future
Done(Fut::Output),
/// The empty variant after the result of a [`MaybeDone`] has been
/// taken using the [`take_output`](MaybeDone::take_output) method.
Gone,
}

impl<Fut: Future + Unpin> Unpin for MaybeDone<Fut> {}

/// Wraps a future into a `MaybeDone`
///
/// # Examples
Expand Down
4 changes: 3 additions & 1 deletion futures-util/src/future/try_maybe_done.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use futures_core::task::{Context, Poll};
#[derive(Debug)]
pub enum TryMaybeDone<Fut: TryFuture> {
/// A not-yet-completed future
Future(Fut),
Future(/* #[pin] */ Fut),
/// The output of the completed future
Done(Fut::Ok),
/// The empty variant after the result of a [`TryMaybeDone`] has been
Expand All @@ -21,6 +21,8 @@ pub enum TryMaybeDone<Fut: TryFuture> {
Gone,
}

impl<Fut: TryFuture + Unpin> Unpin for TryMaybeDone<Fut> {}

/// Wraps a future into a `TryMaybeDone`
pub fn try_maybe_done<Fut: TryFuture>(future: Fut) -> TryMaybeDone<Fut> {
TryMaybeDone::Future(future)
Expand Down