fix: Stabilize stream most method

mio-0-7
k-nasa 5 years ago
parent be60dd9fe7
commit 75223905bd

@ -22,8 +22,6 @@ use try_rfold::TryRFoldFuture;
/// `Item`s from the back, as well as the front. /// `Item`s from the back, as well as the front.
/// ///
/// [`Stream`]: trait.Stream.html /// [`Stream`]: trait.Stream.html
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait DoubleEndedStream: Stream { pub trait DoubleEndedStream: Stream {
#[doc = r#" #[doc = r#"
Attempts to receive the next item from the back of the stream. 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 #[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 { pub trait ExactSizeStream: Stream {
/// Returns the exact number of times the stream will iterate. /// 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> { pub trait Extend<A> {
/// Extends a collection with the contents of a stream. /// Extends a collection with the contents of a stream.
fn extend<'a, T: IntoStream<Item = A> + 'a>( 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 /// [`None`]: https://doc.rust-lang.org/std/option/enum.Option.html#variant.None
/// [`Stream::fuse`]: trait.Stream.html#method.fuse /// [`Stream::fuse`]: trait.Stream.html#method.fuse
/// [`Fuse`]: struct.Fuse.html /// [`Fuse`]: struct.Fuse.html
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait FusedStream: Stream {} pub trait FusedStream: Stream {}
impl<S: FusedStream + ?Sized + Unpin> FusedStream for &mut S {} impl<S: FusedStream + ?Sized + Unpin> FusedStream for &mut S {}

@ -41,8 +41,6 @@ use futures_timer::Delay;
/// # /// #
/// # Ok(()) }) } /// # Ok(()) }) }
/// ``` /// ```
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub fn interval(dur: Duration) -> Interval { pub fn interval(dur: Duration) -> Interval {
Interval { Interval {
delay: Delay::new(dur), delay: Delay::new(dur),
@ -56,8 +54,6 @@ pub fn interval(dur: Duration) -> Interval {
/// documentation for more. /// documentation for more.
/// ///
/// [`interval`]: fn.interval.html /// [`interval`]: fn.interval.html
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)] #[derive(Debug)]
pub struct Interval { pub struct Interval {
delay: Delay, delay: Delay,

@ -300,46 +300,46 @@
//! [`take`]: trait.Stream.html#method.take //! [`take`]: trait.Stream.html#method.take
//! [`min`]: trait.Stream.html#method.min //! [`min`]: trait.Stream.html#method.min
pub use double_ended_stream::DoubleEndedStream;
pub use empty::{empty, Empty}; pub use empty::{empty, Empty};
pub use exact_size_stream::ExactSizeStream;
pub use from_fn::{from_fn, FromFn}; pub use from_fn::{from_fn, FromFn};
pub use from_iter::{from_iter, FromIter}; pub use from_iter::{from_iter, FromIter};
pub use fused_stream::FusedStream;
pub use interval::{interval, Interval};
pub use once::{once, Once}; pub use once::{once, Once};
pub use pending::{pending, Pending};
pub use product::Product;
pub use repeat::{repeat, Repeat}; pub use repeat::{repeat, Repeat};
pub use repeat_with::{repeat_with, RepeatWith}; pub use repeat_with::{repeat_with, RepeatWith};
pub use stream::Merge;
pub use stream::*; pub use stream::*;
pub use successors::{successors, Successors};
pub use sum::Sum;
pub(crate) mod stream; pub(crate) mod stream;
mod double_ended_stream;
mod empty; mod empty;
mod exact_size_stream;
mod from_fn; mod from_fn;
mod from_iter; mod from_iter;
mod fused_stream;
mod interval;
mod once; mod once;
mod pending;
mod product;
mod repeat; mod repeat;
mod repeat_with; mod repeat_with;
mod successors;
mod sum;
cfg_unstable! { cfg_unstable! {
mod double_ended_stream;
mod exact_size_stream;
mod extend;
mod from_stream; mod from_stream;
mod fused_stream;
mod interval;
mod into_stream; mod into_stream;
mod pending; mod extend;
mod product;
mod successors;
mod sum;
pub use double_ended_stream::DoubleEndedStream;
pub use exact_size_stream::ExactSizeStream;
pub use extend::{extend, Extend}; pub use extend::{extend, Extend};
pub use from_stream::FromStream; pub use from_stream::FromStream;
pub use fused_stream::FusedStream;
pub use interval::{interval, Interval};
pub use into_stream::IntoStream; 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::stream::Stream;
use crate::task::{Context, Poll}; use crate::task::{Context, Poll};
#[cfg(feature = "unstable")]
use crate::stream::DoubleEndedStream; use crate::stream::DoubleEndedStream;
/// Creates a stream that yields a single item. /// 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>> { fn poll_next_back(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Poll::Ready(self.project().value.take()) Poll::Ready(self.project().value.take())
} }

@ -1,5 +1,5 @@
use core::pin::Pin;
use core::future::Future; use core::future::Future;
use core::pin::Pin;
use crate::stream::Stream; use crate::stream::Stream;
@ -13,8 +13,6 @@ use crate::stream::Stream;
/// [`product`]: trait.Product.html#tymethod.product /// [`product`]: trait.Product.html#tymethod.product
/// [`FromStream`]: trait.FromStream.html /// [`FromStream`]: trait.FromStream.html
/// [`Stream::product`]: trait.Stream.html#method.product /// [`Stream::product`]: trait.Stream.html#method.product
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait Product<A = Self>: Sized { pub trait Product<A = Self>: Sized {
/// Method which takes a stream and generates `Self` from the elements by /// Method which takes a stream and generates `Self` from the elements by
/// multiplying the items. /// multiplying the items.
@ -23,9 +21,9 @@ pub trait Product<A = Self>: Sized {
S: Stream<Item = A> + 'a; S: Stream<Item = A> + 'a;
} }
use core::ops::Mul;
use core::num::Wrapping;
use crate::stream::stream::StreamExt; use crate::stream::stream::StreamExt;
use core::num::Wrapping;
use core::ops::Mul;
macro_rules! integer_product { macro_rules! integer_product {
(@impls $one: expr, $($a:ty)*) => ($( (@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 } integer_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
float_product!{ f32 f64 } float_product! { f32 f64 }

@ -9,8 +9,6 @@ use crate::task::{Context, Poll};
pin_project! { pin_project! {
#[doc(hidden)] #[doc(hidden)]
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct CountFuture<S> { pub struct CountFuture<S> {
#[pin] #[pin]
stream: S, stream: S,

@ -16,8 +16,6 @@ pin_project! {
/// ///
/// [`merge`]: trait.Stream.html#method.merge /// [`merge`]: trait.Stream.html#method.merge
/// [`Stream`]: trait.Stream.html /// [`Stream`]: trait.Stream.html
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)] #[derive(Debug)]
pub struct Merge<L, R> { pub struct Merge<L, R> {
#[pin] #[pin]

@ -27,7 +27,9 @@ mod chain;
mod cloned; mod cloned;
mod cmp; mod cmp;
mod copied; mod copied;
mod count;
mod cycle; mod cycle;
mod delay;
mod enumerate; mod enumerate;
mod eq; mod eq;
mod filter; mod filter;
@ -47,6 +49,7 @@ mod map;
mod max; mod max;
mod max_by; mod max_by;
mod max_by_key; mod max_by_key;
mod merge;
mod min; mod min;
mod min_by; mod min_by;
mod min_by_key; mod min_by_key;
@ -61,13 +64,17 @@ mod skip_while;
mod step_by; mod step_by;
mod take; mod take;
mod take_while; mod take_while;
mod throttle;
mod timeout;
mod try_fold; mod try_fold;
mod try_for_each; mod try_for_each;
mod unzip;
mod zip; mod zip;
use all::AllFuture; use all::AllFuture;
use any::AnyFuture; use any::AnyFuture;
use cmp::CmpFuture; use cmp::CmpFuture;
use count::CountFuture;
use cycle::Cycle; use cycle::Cycle;
use enumerate::Enumerate; use enumerate::Enumerate;
use eq::EqFuture; use eq::EqFuture;
@ -94,53 +101,48 @@ use partial_cmp::PartialCmpFuture;
use position::PositionFuture; use position::PositionFuture;
use try_fold::TryFoldFuture; use try_fold::TryFoldFuture;
use try_for_each::TryForEachFuture; use try_for_each::TryForEachFuture;
use unzip::UnzipFuture;
pub use chain::Chain; pub use chain::Chain;
pub use cloned::Cloned; pub use cloned::Cloned;
pub use copied::Copied; pub use copied::Copied;
pub use delay::Delay;
pub use filter::Filter; pub use filter::Filter;
pub use fuse::Fuse; pub use fuse::Fuse;
pub use inspect::Inspect; pub use inspect::Inspect;
pub use map::Map; pub use map::Map;
pub use merge::Merge;
pub use scan::Scan; pub use scan::Scan;
pub use skip::Skip; pub use skip::Skip;
pub use skip_while::SkipWhile; pub use skip_while::SkipWhile;
pub use step_by::StepBy; pub use step_by::StepBy;
pub use take::Take; pub use take::Take;
pub use take_while::TakeWhile; pub use take_while::TakeWhile;
pub use throttle::Throttle;
pub use timeout::{Timeout, TimeoutError};
pub use zip::Zip; pub use zip::Zip;
use core::cmp::Ordering; use core::cmp::Ordering;
use core::future::Future;
use core::pin::Pin;
use core::time::Duration;
cfg_unstable! { use crate::stream::{Product, Sum};
use core::future::Future;
use core::pin::Pin;
use core::time::Duration;
cfg_unstable! {
use crate::stream::FromStream;
use crate::stream::into_stream::IntoStream; use crate::stream::into_stream::IntoStream;
use crate::stream::{FromStream, Product, Sum};
use crate::stream::Extend; use crate::stream::Extend;
use count::CountFuture;
use partition::PartitionFuture; use partition::PartitionFuture;
use unzip::UnzipFuture;
pub use merge::Merge;
pub use flatten::Flatten; pub use flatten::Flatten;
pub use flat_map::FlatMap; 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 flatten;
mod flat_map; mod flat_map;
mod partition; mod partition;
mod timeout;
mod throttle;
mod delay;
mod unzip;
} }
extension_trait! { 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> fn throttle(self, d: Duration) -> Throttle<Self>
where where
Self: Sized, 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> fn delay(self, dur: std::time::Duration) -> Delay<Self>
where where
Self: Sized, 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 { fn by_ref(&mut self) -> &mut Self {
self self
} }
@ -1656,8 +1652,6 @@ extension_trait! {
# Ok(()) }) } # Ok(()) }) }
``` ```
"#] "#]
#[cfg(any(feature = "unstable", feature = "docs"))]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn timeout(self, dur: Duration) -> Timeout<Self> fn timeout(self, dur: Duration) -> Timeout<Self>
where where
Self: Stream + Sized, 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>] fn unzip<A, B, FromA, FromB>(self) -> impl Future<Output = (FromA, FromB)> [UnzipFuture<Self, FromA, FromB>]
where where
FromA: Default + Extend<A>, 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> fn merge<U>(self, other: U) -> Merge<Self, U>
where where
Self: Sized, 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>] fn count(self) -> impl Future<Output = usize> [CountFuture<Self>]
where where
Self: Sized, Self: Sized,
@ -2330,8 +2318,6 @@ extension_trait! {
# }) } # }) }
``` ```
"#] "#]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
fn sum<'a, S>( fn sum<'a, S>(
self, self,
) -> impl Future<Output = S> + 'a [Pin<Box<dyn Future<Output = S> + 'a>>] ) -> 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>( fn product<'a, P>(
self, self,
) -> impl Future<Output = P> + 'a [Pin<Box<dyn Future<Output = P> + 'a>>] ) -> 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. /// 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)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct TimeoutError { pub struct TimeoutError {
_private: (), _private: (),

@ -8,8 +8,6 @@ use crate::task::{Context, Poll};
pin_project! { pin_project! {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub struct UnzipFuture<S, FromA, FromB> { pub struct UnzipFuture<S, FromA, FromB> {
#[pin] #[pin]
stream: S, 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> pub fn successors<F, T>(first: Option<T>, succ: F) -> Successors<F, T>
where where
F: FnMut(&T) -> Option<T>, F: FnMut(&T) -> Option<T>,
@ -43,8 +41,6 @@ pin_project! {
/// This stream is constructed by [`successors`] function /// This stream is constructed by [`successors`] function
/// ///
/// [`successors`]: fn.succssors.html /// [`successors`]: fn.succssors.html
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
#[derive(Debug)] #[derive(Debug)]
pub struct Successors<F, T> pub struct Successors<F, T>
where where

@ -13,8 +13,6 @@ use crate::stream::Stream;
/// [`sum`]: trait.Sum.html#tymethod.sum /// [`sum`]: trait.Sum.html#tymethod.sum
/// [`FromStream`]: trait.FromStream.html /// [`FromStream`]: trait.FromStream.html
/// [`Stream::sum`]: trait.Stream.html#method.sum /// [`Stream::sum`]: trait.Stream.html#method.sum
#[cfg(feature = "unstable")]
#[cfg_attr(feature = "docs", doc(cfg(unstable)))]
pub trait Sum<A = Self>: Sized { pub trait Sum<A = Self>: Sized {
/// Method which takes a stream and generates `Self` from the elements by /// Method which takes a stream and generates `Self` from the elements by
/// "summing up" the items. /// "summing up" the items.

Loading…
Cancel
Save