1use core::pin::Pin;
2use core::task::{Context, Poll};
3
4use pin_project_lite::pin_project;
5
6use crate::pull::Pull;
7
8pin_project! {
9 #[must_use = "futures do nothing unless polled"]
14 #[derive(Clone, Debug, Default)]
15 pub struct Next<Prev> {
16 #[pin]
17 prev: Prev,
18 }
19}
20
21impl<Prev> Next<Prev>
22where
23 Self: Future,
24{
25 pub(crate) const fn new(prev: Prev) -> Self {
26 Self { prev }
27 }
28}
29
30impl<Prev> Future for Next<Prev>
31where
32 Prev: Pull,
33{
34 type Output = Option<(Prev::Item, Prev::Meta)>;
35
36 fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
37 let this = self.project();
38 let ctx = <Prev::Ctx<'_> as crate::Context<'_>>::from_task(cx);
39 this.prev.pull(ctx).into_poll()
40 }
41}