Skip to content

Cleanup future module #493

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

Merged
merged 1 commit into from Nov 9, 2019
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 src/future/future/delay.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::future::Future;
use std::pin::Pin;
use std::time::Duration;
use std::future::Future;

use futures_timer::Delay;
use pin_project_lite::pin_project;
Expand All @@ -9,7 +9,7 @@ use crate::task::{Context, Poll};

pin_project! {
#[doc(hidden)]
#[derive(Debug)]
#[allow(missing_debug_implementations)]
pub struct DelayFuture<F> {
#[pin]
future: F,
Expand Down
7 changes: 4 additions & 3 deletions src/future/future/flatten.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::pin::Pin;
use std::future::Future;
use std::pin::Pin;

use crate::future::{IntoFuture};
use crate::future::IntoFuture;
use crate::task::{ready, Context, Poll};

#[derive(Debug)]
#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct FlattenFuture<Fut1, Fut2> {
state: State<Fut1, Fut2>,
}
Expand Down
15 changes: 9 additions & 6 deletions src/future/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ extension_trait! {
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn delay(self, dur: Duration) -> impl Future<Output = Self::Output> [DelayFuture<Self>]
where
Self: Future + Sized
Self: Sized,
{
DelayFuture::new(self, dur)
}
Expand All @@ -173,10 +173,13 @@ extension_trait! {
/// ```
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn flatten(self) -> impl Future<Output = <<Self as Future>::Output as IntoFuture>::Output> [FlattenFuture<Self, <<Self as Future>::Output as IntoFuture>::Future>]
fn flatten(
self,
) -> impl Future<Output = <Self::Output as IntoFuture>::Output>
[FlattenFuture<Self, <Self::Output as IntoFuture>::Future>]
where
Self: Future + Sized,
<Self as Future>::Output: IntoFuture
Self: Sized,
<Self as Future>::Output: IntoFuture,
{
FlattenFuture::new(self)
}
Expand Down Expand Up @@ -214,7 +217,7 @@ extension_trait! {
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn race<F>(
self,
other: F
other: F,
) -> impl Future<Output = <Self as std::future::Future>::Output> [Race<Self, F>]
where
Self: std::future::Future + Sized,
Expand Down Expand Up @@ -258,7 +261,7 @@ extension_trait! {
"#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn try_race<F: std::future::Future, T, E>(
fn try_race<F, T, E>(
self,
other: F
) -> impl Future<Output = <Self as std::future::Future>::Output> [TryRace<Self, F>]
Expand Down
2 changes: 1 addition & 1 deletion src/future/future/race.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::future::Future;
use std::pin::Pin;

use async_macros::MaybeDone;
use pin_project_lite::pin_project;

use crate::task::{Context, Poll};
use std::future::Future;

pin_project! {
#[allow(missing_docs)]
Expand Down
1 change: 0 additions & 1 deletion src/future/into_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pub trait IntoFuture {

impl<T: Future> IntoFuture for T {
type Output = T::Output;

type Future = T;

fn into_future(self) -> Self::Future {
Expand Down
2 changes: 1 addition & 1 deletion src/future/pending.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::future::Future;
use std::marker::PhantomData;
use std::pin::Pin;
use std::future::Future;

use crate::task::{Context, Poll};

Expand Down