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

Stabilize Future adapters and IntoFuture #884

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
55 changes: 20 additions & 35 deletions src/future/future/mod.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
cfg_unstable! {
mod delay;
mod flatten;
mod race;
mod try_race;
mod join;
mod try_join;

use std::time::Duration;
use delay::DelayFuture;
use flatten::FlattenFuture;
use crate::future::IntoFuture;
use race::Race;
use try_race::TryRace;
use join::Join;
use try_join::TryJoin;
}

cfg_unstable_default! {
use crate::future::timeout::TimeoutFuture;
}
mod delay;
mod flatten;
mod race;
mod try_race;
mod join;
mod try_join;

use std::time::Duration;
use delay::DelayFuture;
use flatten::FlattenFuture;
use race::Race;
use try_race::TryRace;
use join::Join;
use try_join::TryJoin;

#[cfg(feature = "default")]
use crate::future::timeout::TimeoutFuture;

use crate::future::IntoFuture;

extension_trait! {
use core::pin::Pin;
Expand Down Expand Up @@ -151,8 +149,6 @@ extension_trait! {
/// dbg!(a.await);
/// # })
/// ```
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn delay(self, dur: Duration) -> impl Future<Output = Self::Output> [DelayFuture<Self>]
where
Self: Sized,
Expand All @@ -174,8 +170,6 @@ extension_trait! {
/// assert_eq!(future.await, 1);
/// # })
/// ```
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn flatten(
self,
) -> impl Future<Output = <Self::Output as IntoFuture>::Output>
Expand Down Expand Up @@ -216,8 +210,6 @@ extension_trait! {
# });
```
"#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn race<F>(
self,
other: F,
Expand Down Expand Up @@ -262,8 +254,6 @@ extension_trait! {
# Ok(()) }) }
```
"#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn try_race<F, T, E>(
self,
other: F
Expand Down Expand Up @@ -299,8 +289,6 @@ extension_trait! {
# });
```
"#]
#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn join<F>(
self,
other: F
Expand Down Expand Up @@ -346,8 +334,6 @@ extension_trait! {
# Ok(()) }) }
```
"#]
#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn try_join<F, A, B, E>(
self,
other: F
Expand Down Expand Up @@ -385,8 +371,7 @@ extension_trait! {
# });
```
"#]
#[cfg(any(all(feature = "default", feature = "unstable"), feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[cfg(feature = "default")]
fn timeout(self, dur: Duration) -> impl Future<Output = Self::Output> [TimeoutFuture<Self>]
where Self: Sized
{
Expand Down
2 changes: 0 additions & 2 deletions src/future/into_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use std::future::Future;
/// }
/// }
/// ```
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait IntoFuture {
/// The type of value produced on completion.
type Output;
Expand Down
11 changes: 5 additions & 6 deletions src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@
//! [`Future::try_race`]: trait.Future.html#method.try_race

cfg_alloc! {
pub use into_future::IntoFuture;
Copy link
Contributor

@taiki-e taiki-e Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you plan to replace this with re-export of std IntoFuture when std IntoFuture's is stable, that would be a breaking change. IIUC, theoretically, there is a way to avoid almost breakage. See rust-lang/futures-rs#2207 and https://github.com/taiki-e/futures-compat-experiment for that.

pub use future::Future;

pub(crate) mod future;
mod into_future;
}

cfg_std! {
Expand All @@ -66,9 +69,5 @@ pub use timeout::{timeout, TimeoutError};
#[cfg(any(feature = "unstable", feature = "default"))]
mod timeout;

cfg_unstable! {
pub use into_future::IntoFuture;
pub(crate) use maybe_done::MaybeDone;
mod into_future;
mod maybe_done;
}
pub(crate) use maybe_done::MaybeDone;
mod maybe_done;