makepad_futures/stream/
next.rs

1use {
2    super::Stream,
3    std::{
4        future::Future,
5        pin::Pin,
6        task::{Context, Poll},
7    },
8};
9
10#[derive(Debug)]
11#[must_use = "futures do nothing unless you `.await` or poll them"]
12pub struct Next<'a, S>
13where
14    S: ?Sized,
15{
16    stream: &'a mut S,
17}
18
19impl<S> Unpin for Next<'_, S> where S: Unpin + ?Sized {}
20
21impl<'a, S> Next<'a, S>
22where
23    S: ?Sized,
24{
25    pub(super) fn new(stream: &'a mut S) -> Self {
26        Self { stream }
27    }
28}
29
30impl<S> Future for Next<'_, S>
31where
32    S: Unpin + Stream + ?Sized,
33{
34    type Output = Option<S::Item>;
35
36    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
37        Pin::new(&mut *self.stream).poll_next(cx)
38    }
39}