1 use core::marker;
2
3 use stream::Stream;
4 use {Poll, Async};
5
6 /// A stream which contains no elements.
7 ///
8 /// This stream can be created with the `stream::empty` function.
9 #[derive(Debug)]
10 #[must_use = "streams do nothing unless polled"]
11 pub struct Empty<T, E> {
12 _data: marker::PhantomData<(T, E)>,
13 }
14
15 /// Creates a stream which contains no elements.
16 ///
17 /// The returned stream will always return `Ready(None)` when polled.
empty<T, E>() -> Empty<T, E>18 pub fn empty<T, E>() -> Empty<T, E> {
19 Empty { _data: marker::PhantomData }
20 }
21
22 impl<T, E> Stream for Empty<T, E> {
23 type Item = T;
24 type Error = E;
25
poll(&mut self) -> Poll<Option<Self::Item>, Self::Error>26 fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
27 Ok(Async::Ready(None))
28 }
29 }
30