forked from mirror/async-std
implement DoubleEndedStream
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
This commit is contained in:
parent
4241f64b1b
commit
23ca060e4c
2 changed files with 24 additions and 0 deletions
22
src/stream/double_ended_stream.rs
Normal file
22
src/stream/double_ended_stream.rs
Normal file
|
@ -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<Option<Self::Item>>;
|
||||||
|
}
|
|
@ -25,8 +25,10 @@ pub use empty::{empty, Empty};
|
||||||
pub use once::{once, Once};
|
pub use once::{once, Once};
|
||||||
pub use repeat::{repeat, Repeat};
|
pub use repeat::{repeat, Repeat};
|
||||||
pub use stream::{Stream, Take};
|
pub use stream::{Stream, Take};
|
||||||
|
pub use double_ended_stream::DoubleEndedStream;
|
||||||
|
|
||||||
mod empty;
|
mod empty;
|
||||||
mod once;
|
mod once;
|
||||||
mod repeat;
|
mod repeat;
|
||||||
mod stream;
|
mod stream;
|
||||||
|
mod double_ended_stream;
|
||||||
|
|
Loading…
Reference in a new issue