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