1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use core::future::Future;
use core::pin::Pin;
use core::task::{Context, Poll};

use crate::ParallelStream;

#[doc(hidden)]
#[allow(missing_debug_implementations)]
pub struct NextFuture<'a, S: Unpin + ?Sized> {
    stream: &'a mut S,
}

impl<'a, S: ParallelStream + Unpin + ?Sized> NextFuture<'a, S> {
    pub(crate) fn new(stream: &'a mut S) -> Self {
        Self { stream }
    }
}

impl<S: ParallelStream + Unpin + ?Sized> Future for NextFuture<'_, S> {
    type Output = Option<S::Item>;

    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        Pin::new(&mut *self.stream).poll_next(cx)
    }
}