broker_tokio/stream/
empty.rs1use crate::stream::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> {}
13
14pub const fn empty<T>() -> Empty<T> {
35 Empty(PhantomData)
36}
37
38impl<T> Stream for Empty<T> {
39 type Item = T;
40
41 fn poll_next(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Option<T>> {
42 Poll::Ready(None)
43 }
44
45 fn size_hint(&self) -> (usize, Option<usize>) {
46 (0, Some(0))
47 }
48}