From 23ca060e4c7eadb0f597e4e799503fe1accb692d Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 10 Sep 2019 17:55:07 +0200 Subject: [PATCH 1/3] implement DoubleEndedStream Signed-off-by: Yoshua Wuyts --- src/stream/double_ended_stream.rs | 22 ++++++++++++++++++++++ src/stream/mod.rs | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 src/stream/double_ended_stream.rs diff --git a/src/stream/double_ended_stream.rs b/src/stream/double_ended_stream.rs new file mode 100644 index 0000000..6f41e61 --- /dev/null +++ b/src/stream/double_ended_stream.rs @@ -0,0 +1,22 @@ +use crate::stream::Stream; + +use std::pin::Pin; +use std::task::{Context, Poll}; + +/// An stream able to yield elements from both ends. +/// +/// Something that implements `DoubleEndedStream` has one extra capability +/// over something that implements [`Stream`]: the ability to also take +/// `Item`s from the back, as well as the front. +/// +/// [`Stream`]: trait.Stream.html +pub trait DoubleEndedStream: Stream { + /// Removes and returns an element from the end of the stream. + /// + /// Returns `None` when there are no more elements. + /// + /// The [trait-level] docs contain more details. + /// + /// [trait-level]: trait.DoubleEndedStream.html + fn poll_next_back(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>; +} diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 8dcc6d5..38fa206 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -25,8 +25,10 @@ pub use empty::{empty, Empty}; pub use once::{once, Once}; pub use repeat::{repeat, Repeat}; pub use stream::{Stream, Take}; +pub use double_ended_stream::DoubleEndedStream; mod empty; mod once; mod repeat; mod stream; +mod double_ended_stream; From 40fb485ccac720f7359fb15c2b88b020ebe1e4bc Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Wed, 11 Sep 2019 14:32:06 +0200 Subject: [PATCH 2/3] cargo fmt Signed-off-by: Yoshua Wuyts --- src/stream/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stream/mod.rs b/src/stream/mod.rs index 38fa206..6081912 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -21,14 +21,14 @@ //! # }) } //! ``` +pub use double_ended_stream::DoubleEndedStream; pub use empty::{empty, Empty}; pub use once::{once, Once}; pub use repeat::{repeat, Repeat}; pub use stream::{Stream, Take}; -pub use double_ended_stream::DoubleEndedStream; +mod double_ended_stream; mod empty; mod once; mod repeat; mod stream; -mod double_ended_stream; From fda74ac0ab36156a09ec6ac1a73f6e73444bafb4 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Fri, 13 Sep 2019 19:36:57 +0200 Subject: [PATCH 3/3] mark as unstable Signed-off-by: Yoshua Wuyts --- src/stream/double_ended_stream.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stream/double_ended_stream.rs b/src/stream/double_ended_stream.rs index 6f41e61..2287cc6 100644 --- a/src/stream/double_ended_stream.rs +++ b/src/stream/double_ended_stream.rs @@ -3,13 +3,14 @@ use crate::stream::Stream; use std::pin::Pin; use std::task::{Context, Poll}; -/// An stream able to yield elements from both ends. +/// A stream able to yield elements from both ends. /// /// Something that implements `DoubleEndedStream` has one extra capability /// over something that implements [`Stream`]: the ability to also take /// `Item`s from the back, as well as the front. /// /// [`Stream`]: trait.Stream.html +#[cfg_attr(feature = "docs", doc(cfg(unstable)))] pub trait DoubleEndedStream: Stream { /// Removes and returns an element from the end of the stream. ///