dfir_rs/compiled/pull/
into_next.rs

1use std::pin::Pin;
2use std::task::{Context, Poll};
3
4use futures::stream::Stream;
5use pin_project_lite::pin_project;
6
7pin_project! {
8    /// A future which resolves with the next item in the stream.
9    pub struct IntoNext<St> {
10        #[pin]
11        pub(crate) stream: St,
12    }
13}
14
15impl<St> IntoNext<St>
16where
17    St: Stream,
18{
19    /// Create a new IntoNext future.
20    pub fn new(stream: St) -> Self {
21        Self { stream }
22    }
23}
24
25impl<St> Future for IntoNext<St>
26where
27    St: Stream,
28{
29    type Output = Option<St::Item>;
30
31    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
32        let this = self.project();
33        this.stream.poll_next(cx)
34    }
35}