fix: Stabilize stream method

pull/719/head
k-nasa 5 years ago
parent 9a62df143f
commit f31878655e

@ -35,7 +35,7 @@ default = [
"pin-project-lite",
]
docs = ["attributes", "unstable", "default"]
unstable = ["std", "broadcaster", "futures-timer"]
unstable = ["std", "broadcaster"]
attributes = ["async-attributes"]
std = [
"alloc",

@ -38,16 +38,14 @@ cfg_std! {
pub use crate::io::prelude::SeekExt as _;
#[doc(no_inline)]
pub use crate::io::prelude::WriteExt as _;
}
cfg_default! {
#[doc(no_inline)]
pub use crate::task_local;
}
cfg_unstable! {
#[doc(no_inline)]
pub use crate::stream::DoubleEndedStream;
#[doc(no_inline)]
pub use crate::stream::ExactSizeStream;
}
cfg_default! {
#[doc(no_inline)]
pub use crate::task_local;
}

@ -1,7 +1,7 @@
use crate::stream::Stream;
use std::pin::Pin;
use std::task::{Context, Poll};
use core::pin::Pin;
use core::task::{Context, Poll};
mod next_back;
mod nth_back;

@ -300,39 +300,42 @@
//! [`take`]: trait.Stream.html#method.take
//! [`min`]: trait.Stream.html#method.min
pub use double_ended_stream::DoubleEndedStream;
pub use empty::{empty, Empty};
pub use exact_size_stream::ExactSizeStream;
pub use from_fn::{from_fn, FromFn};
pub use from_iter::{from_iter, FromIter};
pub use fused_stream::FusedStream;
pub use interval::{interval, Interval};
pub use once::{once, Once};
pub use pending::{pending, Pending};
pub use product::Product;
pub use repeat::{repeat, Repeat};
pub use repeat_with::{repeat_with, RepeatWith};
pub use stream::Merge;
pub use stream::*;
pub use successors::{successors, Successors};
pub use sum::Sum;
pub(crate) mod stream;
mod double_ended_stream;
mod empty;
mod exact_size_stream;
mod from_fn;
mod from_iter;
mod once;
mod repeat;
mod repeat_with;
cfg_std! {
pub use double_ended_stream::DoubleEndedStream;
pub use exact_size_stream::ExactSizeStream;
pub use fused_stream::FusedStream;
pub use interval::{interval, Interval};
pub use pending::{pending, Pending};
pub use product::Product;
pub use successors::{successors, Successors};
pub use sum::Sum;
mod double_ended_stream;
mod exact_size_stream;
mod fused_stream;
mod interval;
mod once;
mod pending;
mod product;
mod repeat;
mod repeat_with;
mod successors;
mod sum;
}
cfg_unstable! {
mod from_stream;

@ -5,6 +5,7 @@ use pin_project_lite::pin_project;
use crate::stream::Stream;
use crate::task::{Context, Poll};
#[cfg(feature = "std")]
use crate::stream::DoubleEndedStream;
/// Creates a stream that yields a single item.
@ -49,6 +50,7 @@ impl<T> Stream for Once<T> {
}
}
#[cfg(feature = "std")]
impl<T> DoubleEndedStream for Once<T> {
fn poll_next_back(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Poll::Ready(self.project().value.take())

@ -1,3 +1,4 @@
use alloc::boxed::Box;
use core::future::Future;
use core::pin::Pin;

@ -27,9 +27,7 @@ mod chain;
mod cloned;
mod cmp;
mod copied;
mod count;
mod cycle;
mod delay;
mod enumerate;
mod eq;
mod filter;
@ -49,7 +47,6 @@ mod map;
mod max;
mod max_by;
mod max_by_key;
mod merge;
mod min;
mod min_by;
mod min_by_key;
@ -64,17 +61,13 @@ mod skip_while;
mod step_by;
mod take;
mod take_while;
mod throttle;
mod timeout;
mod try_fold;
mod try_for_each;
mod unzip;
mod zip;
use all::AllFuture;
use any::AnyFuture;
use cmp::CmpFuture;
use count::CountFuture;
use cycle::Cycle;
use enumerate::Enumerate;
use eq::EqFuture;
@ -101,33 +94,46 @@ use partial_cmp::PartialCmpFuture;
use position::PositionFuture;
use try_fold::TryFoldFuture;
use try_for_each::TryForEachFuture;
use unzip::UnzipFuture;
pub use chain::Chain;
pub use cloned::Cloned;
pub use copied::Copied;
pub use delay::Delay;
pub use filter::Filter;
pub use fuse::Fuse;
pub use inspect::Inspect;
pub use map::Map;
pub use merge::Merge;
pub use scan::Scan;
pub use skip::Skip;
pub use skip_while::SkipWhile;
pub use step_by::StepBy;
pub use take::Take;
pub use take_while::TakeWhile;
pub use throttle::Throttle;
pub use timeout::{Timeout, TimeoutError};
pub use zip::Zip;
use core::cmp::Ordering;
cfg_std! {
use core::time::Duration;
use crate::stream::{Product, Sum};
use alloc::boxed::Box;
use core::future::Future;
use core::pin::Pin;
use core::time::Duration;
use crate::stream::{Product, Sum};
use unzip::UnzipFuture;
use count::CountFuture;
pub use throttle::Throttle;
pub use merge::Merge;
pub use delay::Delay;
pub use timeout::{Timeout, TimeoutError};
mod timeout;
mod throttle;
mod merge;
mod delay;
mod unzip;
mod count;
}
cfg_unstable! {
use crate::stream::FromStream;
@ -357,6 +363,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(feature = "std")]
fn throttle(self, d: Duration) -> Throttle<Self>
where
Self: Sized,
@ -598,6 +605,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(feature = "std")]
fn delay(self, dur: std::time::Duration) -> Delay<Self>
where
Self: Sized,
@ -1652,6 +1660,7 @@ extension_trait! {
# Ok(()) }) }
```
"#]
#[cfg(feature = "std")]
fn timeout(self, dur: Duration) -> Timeout<Self>
where
Self: Stream + Sized,
@ -1816,6 +1825,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(feature = "std")]
fn unzip<A, B, FromA, FromB>(self) -> impl Future<Output = (FromA, FromB)> [UnzipFuture<Self, FromA, FromB>]
where
FromA: Default + Extend<A>,
@ -1913,6 +1923,7 @@ extension_trait! {
# });
```
"#]
#[cfg(feature = "std")]
fn merge<U>(self, other: U) -> Merge<Self, U>
where
Self: Sized,
@ -2058,6 +2069,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(feature = "std")]
fn count(self) -> impl Future<Output = usize> [CountFuture<Self>]
where
Self: Sized,
@ -2318,6 +2330,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(feature = "std")]
fn sum<'a, S>(
self,
) -> impl Future<Output = S> + 'a [Pin<Box<dyn Future<Output = S> + 'a>>]
@ -2362,6 +2375,7 @@ extension_trait! {
# }) }
```
"#]
#[cfg(feature = "std")]
fn product<'a, P>(
self,
) -> impl Future<Output = P> + 'a [Pin<Box<dyn Future<Output = P> + 'a>>]

@ -1,3 +1,4 @@
use alloc::boxed::Box;
use core::future::Future;
use core::pin::Pin;

@ -21,7 +21,7 @@ pub fn abort_on_panic<T>(f: impl FnOnce() -> T) -> T {
}
/// Generates a random number in `0..n`.
#[cfg(any(feature = "unstable", feature = "default"))]
#[cfg(any(feature = "std", feature = "default"))]
pub fn random(n: u32) -> u32 {
use std::cell::Cell;
use std::num::Wrapping;

Loading…
Cancel
Save