Skip to content

Commit 530117d

Browse files
feat: do not require default feature for unstable
1 parent fee3b6f commit 530117d

File tree

11 files changed

+31
-16
lines changed

11 files changed

+31
-16
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ default = [
3434
"num_cpus",
3535
"pin-project-lite",
3636
]
37-
docs = ["attributes", "unstable"]
38-
unstable = ["default", "broadcaster"]
37+
docs = ["attributes", "unstable", "default"]
38+
unstable = ["std", "broadcaster", "futures-timer"]
3939
attributes = ["async-attributes"]
4040
std = [
4141
"crossbeam-utils",

src/future/future/mod.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ cfg_unstable! {
77
mod try_join;
88

99
use std::time::Duration;
10-
1110
use delay::DelayFuture;
1211
use flatten::FlattenFuture;
1312
use crate::future::IntoFuture;
1413
use race::Race;
1514
use try_race::TryRace;
1615
use join::Join;
1716
use try_join::TryJoin;
17+
}
18+
19+
cfg_unstable_default! {
1820
use crate::future::timeout::TimeoutFuture;
1921
}
2022

@@ -149,7 +151,7 @@ extension_trait! {
149151
/// dbg!(a.await);
150152
/// # })
151153
/// ```
152-
#[cfg(all(feature = "default", feature = "unstable"))]
154+
#[cfg(feature = "unstable")]
153155
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
154156
fn delay(self, dur: Duration) -> impl Future<Output = Self::Output> [DelayFuture<Self>]
155157
where
@@ -363,13 +365,13 @@ extension_trait! {
363365
364366
# Example
365367
```
366-
# async_std::task::block_on(async {
368+
# async_std::task::block_on(async {
367369
#
368370
use std::time::Duration;
369371
370372
use async_std::prelude::*;
371373
use async_std::future;
372-
374+
373375
let fut = future::ready(0);
374376
let dur = Duration::from_millis(100);
375377
let res = fut.timeout(dur).await;
@@ -383,7 +385,7 @@ extension_trait! {
383385
# });
384386
```
385387
"#]
386-
#[cfg(any(feature = "unstable", feature = "docs"))]
388+
#[cfg(any(all(feature = "default", feature = "unstable"), feature = "docs"))]
387389
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
388390
fn timeout(self, dur: Duration) -> impl Future<Output = Self::Output> [TimeoutFuture<Self>]
389391
where Self: Sized

src/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ cfg_default! {
321321
mod stdout;
322322
}
323323

324-
cfg_unstable! {
324+
cfg_unstable_default! {
325325
pub use stderr::StderrLock;
326326
pub use stdin::StdinLock;
327327
pub use stdout::StdoutLock;

src/io/read/bytes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<T: Read + Unpin> Stream for Bytes<T> {
3232
}
3333
}
3434

35-
#[cfg(test)]
35+
#[cfg(all(test, default))]
3636
mod tests {
3737
use crate::io;
3838
use crate::prelude::*;

src/io/read/chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
165165
}
166166
}
167167

168-
#[cfg(test)]
168+
#[cfg(all(test, default))]
169169
mod tests {
170170
use crate::io;
171171
use crate::prelude::*;

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ cfg_unstable! {
266266
mod option;
267267
mod string;
268268
mod collections;
269+
}
269270

271+
cfg_unstable_default! {
270272
#[doc(inline)]
271273
pub use std::{write, writeln};
272274
}

src/stream/stream/count.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::task::{Context, Poll};
99
pin_project! {
1010
#[doc(hidden)]
1111
#[allow(missing_debug_implementations)]
12-
#[cfg(all(feature = "default", feature = "unstable"))]
12+
#[cfg(feature = "unstable")]
1313
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
1414
pub struct CountFuture<S> {
1515
#[pin]

src/stream/stream/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ extension_trait! {
355355
# }) }
356356
```
357357
"#]
358-
#[cfg(all(feature = "default", feature = "unstable"))]
358+
#[cfg(feature = "unstable")]
359359
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
360360
fn throttle(self, d: Duration) -> Throttle<Self>
361361
where
@@ -1507,7 +1507,7 @@ extension_trait! {
15071507
# }) }
15081508
```
15091509
"#]
1510-
#[cfg(all(feature = "default", feature = "unstable"))]
1510+
#[cfg(feature = "unstable")]
15111511
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
15121512
fn by_ref(&mut self) -> &mut Self {
15131513
self

src/stream/stream/partition.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::task::{Context, Poll};
88

99
pin_project! {
1010
#[derive(Debug)]
11-
#[cfg(all(feature = "default", feature = "unstable"))]
11+
#[cfg(feature = "unstable")]
1212
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
1313
pub struct PartitionFuture<S, F, B> {
1414
#[pin]

src/stream/stream/unzip.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::task::{Context, Poll};
88

99
pin_project! {
1010
#[derive(Clone, Debug)]
11-
#[cfg(all(feature = "default", feature = "unstable"))]
11+
#[cfg(feature = "unstable")]
1212
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
1313
pub struct UnzipFuture<S, FromA, FromB> {
1414
#[pin]

src/utils.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
1919
}
2020

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

92+
/// Declares unstable and default items.
93+
#[doc(hidden)]
94+
macro_rules! cfg_unstable_default {
95+
($($item:item)*) => {
96+
$(
97+
#[cfg(all(feature = "default", feature = "unstable"))]
98+
#[cfg_attr(feature = "docs", doc(unstable))]
99+
$item
100+
)*
101+
}
102+
}
103+
93104
/// Declares Unix-specific items.
94105
#[doc(hidden)]
95106
macro_rules! cfg_unix {

0 commit comments

Comments
 (0)