Skip to content

feat: do not require default feature for unstable #647

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
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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@ default = [
"num_cpus",
"pin-project-lite",
]
docs = ["attributes", "unstable"]
unstable = ["default", "broadcaster"]
docs = ["attributes", "unstable", "default"]
unstable = ["std", "broadcaster", "futures-timer"]
attributes = ["async-attributes"]
std = [
"crossbeam-utils",
12 changes: 7 additions & 5 deletions src/future/future/mod.rs
Original file line number Diff line number Diff line change
@@ -7,14 +7,16 @@ cfg_unstable! {
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;
}

@@ -149,7 +151,7 @@ extension_trait! {
/// dbg!(a.await);
/// # })
/// ```
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn delay(self, dur: Duration) -> impl Future<Output = Self::Output> [DelayFuture<Self>]
where
@@ -363,13 +365,13 @@ extension_trait! {

# Example
```
# async_std::task::block_on(async {
# async_std::task::block_on(async {
#
use std::time::Duration;

use async_std::prelude::*;
use async_std::future;

let fut = future::ready(0);
let dur = Duration::from_millis(100);
let res = fut.timeout(dur).await;
@@ -383,7 +385,7 @@ extension_trait! {
# });
```
"#]
#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg(any(all(feature = "default", feature = "unstable"), feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn timeout(self, dur: Duration) -> impl Future<Output = Self::Output> [TimeoutFuture<Self>]
where Self: Sized
2 changes: 1 addition & 1 deletion src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -321,7 +321,7 @@ cfg_default! {
mod stdout;
}

cfg_unstable! {
cfg_unstable_default! {
pub use stderr::StderrLock;
pub use stdin::StdinLock;
pub use stdout::StdoutLock;
2 changes: 1 addition & 1 deletion src/io/read/bytes.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ impl<T: Read + Unpin> Stream for Bytes<T> {
}
}

#[cfg(test)]
#[cfg(all(test, default))]
mod tests {
use crate::io;
use crate::prelude::*;
2 changes: 1 addition & 1 deletion src/io/read/chain.rs
Original file line number Diff line number Diff line change
@@ -165,7 +165,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
}
}

#[cfg(test)]
#[cfg(all(test, default))]
mod tests {
use crate::io;
use crate::prelude::*;
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -266,7 +266,9 @@ cfg_unstable! {
mod option;
mod string;
mod collections;
}

cfg_unstable_default! {
#[doc(inline)]
pub use std::{write, writeln};
}
2 changes: 1 addition & 1 deletion src/stream/stream/count.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use crate::task::{Context, Poll};
pin_project! {
#[doc(hidden)]
#[allow(missing_debug_implementations)]
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct CountFuture<S> {
#[pin]
4 changes: 2 additions & 2 deletions src/stream/stream/mod.rs
Original file line number Diff line number Diff line change
@@ -355,7 +355,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn throttle(self, d: Duration) -> Throttle<Self>
where
@@ -1507,7 +1507,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn by_ref(&mut self) -> &mut Self {
self
2 changes: 1 addition & 1 deletion src/stream/stream/partition.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use crate::task::{Context, Poll};

pin_project! {
#[derive(Debug)]
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct PartitionFuture<S, F, B> {
#[pin]
2 changes: 1 addition & 1 deletion src/stream/stream/unzip.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use crate::task::{Context, Poll};

pin_project! {
#[derive(Clone, Debug)]
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct UnzipFuture<S, FromA, FromB> {
#[pin]
14 changes: 13 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
}

/// Generates a random number in `0..n`.
#[cfg(feature = "default")]
#[cfg(any(feature = "unstable", feature = "default"))]
pub fn random(n: u32) -> u32 {
use std::cell::Cell;
use std::num::Wrapping;
@@ -90,6 +90,18 @@ macro_rules! cfg_unstable {
}
}

/// Declares unstable and default items.
#[doc(hidden)]
macro_rules! cfg_unstable_default {
($($item:item)*) => {
$(
#[cfg(all(feature = "default", feature = "unstable"))]
#[cfg_attr(feature = "docs", doc(unstable))]
$item
)*
}
}

/// Declares Unix-specific items.
#[doc(hidden)]
macro_rules! cfg_unix {