diff --git a/src/future/timeout.rs b/src/future/timeout.rs index e433bf18..bf7a6ff3 100644 --- a/src/future/timeout.rs +++ b/src/future/timeout.rs @@ -29,6 +29,7 @@ use crate::task::{Context, Poll}; /// # Ok(()) }) } /// ``` #[cfg_attr(feature = "docs", doc(cfg(unstable)))] +#[cfg(feature = "unstable")] pub async fn timeout(dur: Duration, f: F) -> Result where F: Future, @@ -69,6 +70,7 @@ impl Future for TimeoutFuture { /// An error returned when a future times out. #[cfg_attr(feature = "docs", doc(cfg(unstable)))] +#[cfg(feature = "unstable")] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct TimeoutError { _private: (), diff --git a/src/lib.rs b/src/lib.rs index dfa9a07a..83647bbc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,17 +42,24 @@ #![doc(test(attr(allow(unused_extern_crates, unused_variables))))] #![doc(html_logo_url = "https://async.rs/images/logo--hero.svg")] +use cfg_if::cfg_if; + pub mod fs; pub mod future; pub mod io; pub mod net; pub mod os; pub mod prelude; -mod result; pub mod stream; pub mod sync; pub mod task; -mod vec; + +cfg_if! { + if #[cfg(any(feature = "unstable", feature = "docs"))] { + mod vec; + mod result; + } +} #[cfg_attr(feature = "docs", doc(cfg(unstable)))] #[cfg(feature = "unstable")] diff --git a/src/stream/double_ended_stream.rs b/src/stream/double_ended_stream.rs index 2287cc64..bb5df74f 100644 --- a/src/stream/double_ended_stream.rs +++ b/src/stream/double_ended_stream.rs @@ -11,6 +11,7 @@ use std::task::{Context, Poll}; /// /// [`Stream`]: trait.Stream.html #[cfg_attr(feature = "docs", doc(cfg(unstable)))] +#[cfg(feature = "unstable")] pub trait DoubleEndedStream: Stream { /// Removes and returns an element from the end of the stream. /// diff --git a/src/stream/from_stream.rs b/src/stream/from_stream.rs index 91d3e24b..58b2ad17 100644 --- a/src/stream/from_stream.rs +++ b/src/stream/from_stream.rs @@ -11,6 +11,7 @@ use std::pin::Pin; /// /// [`IntoStream`]: trait.IntoStream.html #[cfg_attr(feature = "docs", doc(cfg(unstable)))] +#[cfg(feature = "unstable")] pub trait FromStream { /// Creates a value from a stream. /// diff --git a/src/stream/into_stream.rs b/src/stream/into_stream.rs index b2913170..0a986a8a 100644 --- a/src/stream/into_stream.rs +++ b/src/stream/into_stream.rs @@ -14,6 +14,7 @@ use futures_core::stream::Stream; /// /// [`FromStream`]: trait.FromStream.html #[cfg_attr(feature = "docs", doc(cfg(unstable)))] +#[cfg(feature = "unstable")] pub trait IntoStream { /// The type of the elements being iterated over. type Item; diff --git a/src/stream/mod.rs b/src/stream/mod.rs index ec1c23bc..36cf3a4e 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -21,18 +21,26 @@ //! # }) } //! ``` -pub use double_ended_stream::DoubleEndedStream; +use cfg_if::cfg_if; + pub use empty::{empty, Empty}; -pub use from_stream::FromStream; -pub use into_stream::IntoStream; pub use once::{once, Once}; pub use repeat::{repeat, Repeat}; pub use stream::{Fuse, Scan, Stream, Take, Zip}; -mod double_ended_stream; mod empty; -mod from_stream; -mod into_stream; mod once; mod repeat; mod stream; + +cfg_if! { + if #[cfg(any(feature = "unstable", feature = "docs"))] { + mod double_ended_stream; + mod from_stream; + mod into_stream; + + pub use double_ended_stream::DoubleEndedStream; + pub use from_stream::FromStream; + pub use into_stream::IntoStream; + } +} diff --git a/src/stream/stream/mod.rs b/src/stream/stream/mod.rs index 62f1b4b5..3a02a5c8 100644 --- a/src/stream/stream/mod.rs +++ b/src/stream/stream/mod.rs @@ -52,7 +52,6 @@ use min_by::MinByFuture; use next::NextFuture; use nth::NthFuture; -use super::from_stream::FromStream; use std::cmp::Ordering; use std::marker::PhantomData; use std::pin::Pin; @@ -60,6 +59,12 @@ use std::task::{Context, Poll}; use cfg_if::cfg_if; +cfg_if! { + if #[cfg(any(feature = "unstable", feature = "docs"))] { + use crate::stream::FromStream; + } +} + cfg_if! { if #[cfg(feature = "docs")] { #[doc(hidden)] @@ -748,6 +753,8 @@ pub trait Stream { /// /// [`stream`]: trait.Stream.html#tymethod.next #[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead (TODO)"] + #[cfg_attr(feature = "docs", doc(cfg(unstable)))] + #[cfg(feature = "unstable")] fn collect<'a, B>(self) -> dyn_ret!('a, B) where Self: futures_core::stream::Stream + Sized + Send + 'a,