From d4f38e783fd18ece0fe691dcee78a8a41aa55d1a Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Sat, 9 Nov 2019 17:26:19 +0100 Subject: [PATCH] Cleanup future module --- src/future/future/delay.rs | 4 ++-- src/future/future/flatten.rs | 7 ++++--- src/future/future/mod.rs | 15 +++++++++------ src/future/future/race.rs | 2 +- src/future/into_future.rs | 1 - src/future/pending.rs | 2 +- 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/future/future/delay.rs b/src/future/future/delay.rs index 45658f45..641084ff 100644 --- a/src/future/future/delay.rs +++ b/src/future/future/delay.rs @@ -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; @@ -9,7 +9,7 @@ use crate::task::{Context, Poll}; pin_project! { #[doc(hidden)] - #[derive(Debug)] + #[allow(missing_debug_implementations)] pub struct DelayFuture { #[pin] future: F, diff --git a/src/future/future/flatten.rs b/src/future/future/flatten.rs index 1d316440..a07b140c 100644 --- a/src/future/future/flatten.rs +++ b/src/future/future/flatten.rs @@ -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 { state: State, } diff --git a/src/future/future/mod.rs b/src/future/future/mod.rs index 729ace7c..5fdaf4b1 100644 --- a/src/future/future/mod.rs +++ b/src/future/future/mod.rs @@ -152,7 +152,7 @@ extension_trait! { #[cfg_attr(feature = "docs", doc(cfg(unstable)))] fn delay(self, dur: Duration) -> impl Future [DelayFuture] where - Self: Future + Sized + Self: Sized, { DelayFuture::new(self, dur) } @@ -173,10 +173,13 @@ extension_trait! { /// ``` #[cfg(feature = "unstable")] #[cfg_attr(feature = "docs", doc(cfg(unstable)))] - fn flatten(self) -> impl Future::Output as IntoFuture>::Output> [FlattenFuture::Output as IntoFuture>::Future>] + fn flatten( + self, + ) -> impl Future::Output> + [FlattenFuture::Future>] where - Self: Future + Sized, - ::Output: IntoFuture + Self: Sized, + ::Output: IntoFuture, { FlattenFuture::new(self) } @@ -214,7 +217,7 @@ extension_trait! { #[cfg_attr(feature = "docs", doc(cfg(unstable)))] fn race( self, - other: F + other: F, ) -> impl Future::Output> [Race] where Self: std::future::Future + Sized, @@ -258,7 +261,7 @@ extension_trait! { "#] #[cfg(feature = "unstable")] #[cfg_attr(feature = "docs", doc(cfg(unstable)))] - fn try_race( + fn try_race( self, other: F ) -> impl Future::Output> [TryRace] diff --git a/src/future/future/race.rs b/src/future/future/race.rs index 2fd604a7..ed034f05 100644 --- a/src/future/future/race.rs +++ b/src/future/future/race.rs @@ -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)] diff --git a/src/future/into_future.rs b/src/future/into_future.rs index a9a81875..8e5e5e04 100644 --- a/src/future/into_future.rs +++ b/src/future/into_future.rs @@ -45,7 +45,6 @@ pub trait IntoFuture { impl IntoFuture for T { type Output = T::Output; - type Future = T; fn into_future(self) -> Self::Future { diff --git a/src/future/pending.rs b/src/future/pending.rs index 39f7cab1..968972b5 100644 --- a/src/future/pending.rs +++ b/src/future/pending.rs @@ -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};