use core::marker; use core::pin::Pin; use futures_core::stream::{FusedStream, Stream}; use futures_core::task::{Context, Poll}; /// Stream for the [`pending()`] function. #[derive(Debug)] #[must_use = "streams do nothing unless polled"] pub struct Pending { _data: marker::PhantomData, } /// Creates a stream which never returns any elements. /// /// The returned stream will always return `Pending` when polled. pub fn pending() -> Pending { Pending { _data: marker::PhantomData } } impl Unpin for Pending {} impl FusedStream for Pending { fn is_terminated(&self) -> bool { true } } impl Stream for Pending { type Item = T; fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll> { Poll::Pending } fn size_hint(&self) -> (usize, Option) { (0, Some(0)) } }