Merge pull request #647 from dignifiedquire/feat/unstable-without-default

feat: do not require default feature for unstable
split-by-pattern
Yoshua Wuyts 5 years ago committed by GitHub
commit 98d45f4be1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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",

@ -7,7 +7,6 @@ cfg_unstable! {
mod try_join;
use std::time::Duration;
use delay::DelayFuture;
use flatten::FlattenFuture;
use crate::future::IntoFuture;
@ -15,6 +14,9 @@ cfg_unstable! {
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

@ -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;

@ -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::*;

@ -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::*;

@ -266,7 +266,9 @@ cfg_unstable! {
mod option;
mod string;
mod collections;
}
cfg_unstable_default! {
#[doc(inline)]
pub use std::{write, writeln};
}

@ -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]

@ -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

@ -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]

@ -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]

@ -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 {

Loading…
Cancel
Save