1 use core::marker;
2 use core::pin::Pin;
3 use futures_core::stream::{FusedStream, Stream};
4 use futures_core::task::{Context, Poll};
5 
6 /// Stream for the [`pending()`] function.
7 #[derive(Debug)]
8 #[must_use = "streams do nothing unless polled"]
9 pub struct Pending<T> {
10     _data: marker::PhantomData<T>,
11 }
12 
13 /// Creates a stream which never returns any elements.
14 ///
15 /// The returned stream will always return `Pending` when polled.
pending<T>() -> Pending<T>16 pub fn pending<T>() -> Pending<T> {
17     Pending { _data: marker::PhantomData }
18 }
19 
20 impl<T> Unpin for Pending<T> {}
21 
22 impl<T> FusedStream for Pending<T> {
is_terminated(&self) -> bool23     fn is_terminated(&self) -> bool {
24         true
25     }
26 }
27 
28 impl<T> Stream for Pending<T> {
29     type Item = T;
30 
poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>>31     fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<Self::Item>> {
32         Poll::Pending
33     }
34 
size_hint(&self) -> (usize, Option<usize>)35     fn size_hint(&self) -> (usize, Option<usize>) {
36         (0, Some(0))
37     }
38 }
39