forked from mirror/async-std
fix: Stabilize stream most method
This commit is contained in:
parent
be60dd9fe7
commit
75223905bd
15 changed files with 43 additions and 89 deletions
|
@ -22,8 +22,6 @@ use try_rfold::TryRFoldFuture;
|
|||
/// `Item`s from the back, as well as the front.
|
||||
///
|
||||
/// [`Stream`]: trait.Stream.html
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub trait DoubleEndedStream: Stream {
|
||||
#[doc = r#"
|
||||
Attempts to receive the next item from the back of the stream.
|
||||
|
|
|
@ -76,8 +76,6 @@ pub use crate::stream::Stream;
|
|||
/// # });
|
||||
/// ```
|
||||
#[allow(clippy::len_without_is_empty)] // ExactSizeIterator::is_empty is unstable
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub trait ExactSizeStream: Stream {
|
||||
/// Returns the exact number of times the stream will iterate.
|
||||
///
|
||||
|
|
|
@ -27,8 +27,6 @@ use crate::stream::IntoStream;
|
|||
/// #
|
||||
/// # })
|
||||
/// ```
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub trait Extend<A> {
|
||||
/// Extends a collection with the contents of a stream.
|
||||
fn extend<'a, T: IntoStream<Item = A> + 'a>(
|
||||
|
|
|
@ -14,8 +14,6 @@ use crate::stream::Stream;
|
|||
/// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
|
||||
/// [`Stream::fuse`]: trait.Stream.html#method.fuse
|
||||
/// [`Fuse`]: struct.Fuse.html
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub trait FusedStream: Stream {}
|
||||
|
||||
impl<S: FusedStream + ?Sized + Unpin> FusedStream for &mut S {}
|
||||
|
|
|
@ -41,8 +41,6 @@ use futures_timer::Delay;
|
|||
/// #
|
||||
/// # Ok(()) }) }
|
||||
/// ```
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub fn interval(dur: Duration) -> Interval {
|
||||
Interval {
|
||||
delay: Delay::new(dur),
|
||||
|
@ -56,8 +54,6 @@ pub fn interval(dur: Duration) -> Interval {
|
|||
/// documentation for more.
|
||||
///
|
||||
/// [`interval`]: fn.interval.html
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
#[derive(Debug)]
|
||||
pub struct Interval {
|
||||
delay: Delay,
|
||||
|
|
|
@ -300,46 +300,46 @@
|
|||
//! [`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 fused_stream;
|
||||
mod interval;
|
||||
mod once;
|
||||
mod pending;
|
||||
mod product;
|
||||
mod repeat;
|
||||
mod repeat_with;
|
||||
mod successors;
|
||||
mod sum;
|
||||
|
||||
cfg_unstable! {
|
||||
mod double_ended_stream;
|
||||
mod exact_size_stream;
|
||||
mod extend;
|
||||
mod from_stream;
|
||||
mod fused_stream;
|
||||
mod interval;
|
||||
mod into_stream;
|
||||
mod pending;
|
||||
mod product;
|
||||
mod successors;
|
||||
mod sum;
|
||||
mod extend;
|
||||
|
||||
pub use double_ended_stream::DoubleEndedStream;
|
||||
pub use exact_size_stream::ExactSizeStream;
|
||||
pub use extend::{extend, Extend};
|
||||
pub use from_stream::FromStream;
|
||||
pub use fused_stream::FusedStream;
|
||||
pub use interval::{interval, Interval};
|
||||
pub use into_stream::IntoStream;
|
||||
pub use pending::{pending, Pending};
|
||||
pub use product::Product;
|
||||
pub use stream::Merge;
|
||||
pub use successors::{successors, Successors};
|
||||
pub use sum::Sum;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ use pin_project_lite::pin_project;
|
|||
use crate::stream::Stream;
|
||||
use crate::task::{Context, Poll};
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
use crate::stream::DoubleEndedStream;
|
||||
|
||||
/// Creates a stream that yields a single item.
|
||||
|
@ -50,8 +49,7 @@ impl<T> Stream for Once<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable")]
|
||||
impl <T> DoubleEndedStream for Once<T> {
|
||||
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,5 +1,5 @@
|
|||
use core::pin::Pin;
|
||||
use core::future::Future;
|
||||
use core::pin::Pin;
|
||||
|
||||
use crate::stream::Stream;
|
||||
|
||||
|
@ -13,8 +13,6 @@ use crate::stream::Stream;
|
|||
/// [`product`]: trait.Product.html#tymethod.product
|
||||
/// [`FromStream`]: trait.FromStream.html
|
||||
/// [`Stream::product`]: trait.Stream.html#method.product
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub trait Product<A = Self>: Sized {
|
||||
/// Method which takes a stream and generates `Self` from the elements by
|
||||
/// multiplying the items.
|
||||
|
@ -23,9 +21,9 @@ pub trait Product<A = Self>: Sized {
|
|||
S: Stream<Item = A> + 'a;
|
||||
}
|
||||
|
||||
use core::ops::Mul;
|
||||
use core::num::Wrapping;
|
||||
use crate::stream::stream::StreamExt;
|
||||
use core::num::Wrapping;
|
||||
use core::ops::Mul;
|
||||
|
||||
macro_rules! integer_product {
|
||||
(@impls $one: expr, $($a:ty)*) => ($(
|
||||
|
@ -75,5 +73,5 @@ macro_rules! float_product {
|
|||
);
|
||||
}
|
||||
|
||||
integer_product!{ i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
|
||||
float_product!{ f32 f64 }
|
||||
integer_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
|
||||
float_product! { f32 f64 }
|
||||
|
|
|
@ -9,8 +9,6 @@ use crate::task::{Context, Poll};
|
|||
pin_project! {
|
||||
#[doc(hidden)]
|
||||
#[allow(missing_debug_implementations)]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub struct CountFuture<S> {
|
||||
#[pin]
|
||||
stream: S,
|
||||
|
|
|
@ -16,8 +16,6 @@ pin_project! {
|
|||
///
|
||||
/// [`merge`]: trait.Stream.html#method.merge
|
||||
/// [`Stream`]: trait.Stream.html
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
#[derive(Debug)]
|
||||
pub struct Merge<L, R> {
|
||||
#[pin]
|
||||
|
|
|
@ -27,7 +27,9 @@ mod chain;
|
|||
mod cloned;
|
||||
mod cmp;
|
||||
mod copied;
|
||||
mod count;
|
||||
mod cycle;
|
||||
mod delay;
|
||||
mod enumerate;
|
||||
mod eq;
|
||||
mod filter;
|
||||
|
@ -47,6 +49,7 @@ mod map;
|
|||
mod max;
|
||||
mod max_by;
|
||||
mod max_by_key;
|
||||
mod merge;
|
||||
mod min;
|
||||
mod min_by;
|
||||
mod min_by_key;
|
||||
|
@ -61,13 +64,17 @@ 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;
|
||||
|
@ -94,53 +101,48 @@ 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;
|
||||
use core::future::Future;
|
||||
use core::pin::Pin;
|
||||
use core::time::Duration;
|
||||
|
||||
use crate::stream::{Product, Sum};
|
||||
|
||||
cfg_unstable! {
|
||||
use core::future::Future;
|
||||
use core::pin::Pin;
|
||||
use core::time::Duration;
|
||||
|
||||
use crate::stream::FromStream;
|
||||
use crate::stream::into_stream::IntoStream;
|
||||
use crate::stream::{FromStream, Product, Sum};
|
||||
use crate::stream::Extend;
|
||||
|
||||
use count::CountFuture;
|
||||
use partition::PartitionFuture;
|
||||
use unzip::UnzipFuture;
|
||||
|
||||
pub use merge::Merge;
|
||||
pub use flatten::Flatten;
|
||||
pub use flat_map::FlatMap;
|
||||
pub use timeout::{TimeoutError, Timeout};
|
||||
pub use throttle::Throttle;
|
||||
pub use delay::Delay;
|
||||
|
||||
mod count;
|
||||
mod merge;
|
||||
|
||||
mod flatten;
|
||||
mod flat_map;
|
||||
mod partition;
|
||||
mod timeout;
|
||||
mod throttle;
|
||||
mod delay;
|
||||
mod unzip;
|
||||
}
|
||||
|
||||
extension_trait! {
|
||||
|
@ -355,8 +357,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn throttle(self, d: Duration) -> Throttle<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -598,8 +598,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(any(feature = "unstable", feature = "docs"))]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn delay(self, dur: std::time::Duration) -> Delay<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -1511,8 +1509,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn by_ref(&mut self) -> &mut Self {
|
||||
self
|
||||
}
|
||||
|
@ -1656,8 +1652,6 @@ extension_trait! {
|
|||
# Ok(()) }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(any(feature = "unstable", feature = "docs"))]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn timeout(self, dur: Duration) -> Timeout<Self>
|
||||
where
|
||||
Self: Stream + Sized,
|
||||
|
@ -1822,8 +1816,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn unzip<A, B, FromA, FromB>(self) -> impl Future<Output = (FromA, FromB)> [UnzipFuture<Self, FromA, FromB>]
|
||||
where
|
||||
FromA: Default + Extend<A>,
|
||||
|
@ -1921,8 +1913,6 @@ extension_trait! {
|
|||
# });
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn merge<U>(self, other: U) -> Merge<Self, U>
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2068,8 +2058,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn count(self) -> impl Future<Output = usize> [CountFuture<Self>]
|
||||
where
|
||||
Self: Sized,
|
||||
|
@ -2330,8 +2318,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn sum<'a, S>(
|
||||
self,
|
||||
) -> impl Future<Output = S> + 'a [Pin<Box<dyn Future<Output = S> + 'a>>]
|
||||
|
@ -2376,8 +2362,6 @@ extension_trait! {
|
|||
# }) }
|
||||
```
|
||||
"#]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
fn product<'a, P>(
|
||||
self,
|
||||
) -> impl Future<Output = P> + 'a [Pin<Box<dyn Future<Output = P> + 'a>>]
|
||||
|
|
|
@ -47,8 +47,6 @@ impl<S: Stream> Stream for Timeout<S> {
|
|||
}
|
||||
|
||||
/// An error returned when a stream times out.
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
#[cfg(any(feature = "unstable", feature = "docs"))]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct TimeoutError {
|
||||
_private: (),
|
||||
|
|
|
@ -8,8 +8,6 @@ use crate::task::{Context, Poll};
|
|||
|
||||
pin_project! {
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub struct UnzipFuture<S, FromA, FromB> {
|
||||
#[pin]
|
||||
stream: S,
|
||||
|
|
|
@ -27,8 +27,6 @@ use pin_project_lite::pin_project;
|
|||
/// #
|
||||
/// # }) }
|
||||
/// ```
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub fn successors<F, T>(first: Option<T>, succ: F) -> Successors<F, T>
|
||||
where
|
||||
F: FnMut(&T) -> Option<T>,
|
||||
|
@ -43,8 +41,6 @@ pin_project! {
|
|||
/// This stream is constructed by [`successors`] function
|
||||
///
|
||||
/// [`successors`]: fn.succssors.html
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
#[derive(Debug)]
|
||||
pub struct Successors<F, T>
|
||||
where
|
||||
|
|
|
@ -13,8 +13,6 @@ use crate::stream::Stream;
|
|||
/// [`sum`]: trait.Sum.html#tymethod.sum
|
||||
/// [`FromStream`]: trait.FromStream.html
|
||||
/// [`Stream::sum`]: trait.Stream.html#method.sum
|
||||
#[cfg(feature = "unstable")]
|
||||
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
|
||||
pub trait Sum<A = Self>: Sized {
|
||||
/// Method which takes a stream and generates `Self` from the elements by
|
||||
/// "summing up" the items.
|
||||
|
|
Loading…
Reference in a new issue