1use crate::Stream;
2
3use core::marker::PhantomData;
4use core::pin::Pin;
5use core::task::{Context, Poll};
6
7#[derive(Debug)]
9#[must_use = "streams do nothing unless polled"]
10pub struct Empty<T>(PhantomData<T>);
11
12impl<T> Unpin for Empty<T> {}
13unsafe impl<T> Send for Empty<T> {}
14unsafe impl<T> Sync for Empty<T> {}
15
16pub const fn empty<T>() -> Empty<T> {
37 Empty(PhantomData)
38}
39
40impl<T> Stream for Empty<T> {
41 type Item = T;
42
43 fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<T>> {
44 Poll::Ready(None)
45 }
46
47 fn size_hint(&self) -> (usize, Option<usize>) {
48 (0, Some(0))
49 }
50}