channels_io/source/
next.rs

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