use Poll;
use task;
pub trait Stream {
type Item;
type Error;
fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error>;
}
impl<'a, S: ?Sized + Stream> Stream for &'a mut S {
type Item = S::Item;
type Error = S::Error;
fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
(**self).poll_next(cx)
}
}
if_std! {
use Async;
use never::Never;
impl<S: ?Sized + Stream> Stream for ::std::boxed::Box<S> {
type Item = S::Item;
type Error = S::Error;
fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
(**self).poll_next(cx)
}
}
#[cfg(feature = "nightly")]
impl<S: ?Sized + Stream> Stream for ::std::boxed::PinBox<S> {
type Item = S::Item;
type Error = S::Error;
fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
unsafe { ::core::mem::Pin::get_mut(&mut self.as_pin()).poll_next(cx) }
}
}
impl<S: Stream> Stream for ::std::panic::AssertUnwindSafe<S> {
type Item = S::Item;
type Error = S::Error;
fn poll_next(&mut self, cx: &mut task::Context) -> Poll<Option<S::Item>, S::Error> {
self.0.poll_next(cx)
}
}
impl<T> Stream for ::std::collections::VecDeque<T> {
type Item = T;
type Error = Never;
fn poll_next(&mut self, _cx: &mut task::Context) -> Poll<Option<Self::Item>, Self::Error> {
Ok(Async::Ready(self.pop_front()))
}
}
}