Skip to content

Commit

Permalink
Fix Unpin impl of (Try)MaybeDone
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jan 14, 2021
1 parent 7f509b5 commit 7d85caa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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

0 comments on commit 7d85caa

Please sign in to comment.