1 //! Definition of the Empty combinator, a future that's never ready.
2
3 use core::marker;
4
5 use {Future, Poll, Async};
6
7 /// A future which is never resolved.
8 ///
9 /// This future can be created with the `empty` function.
10 #[derive(Debug)]
11 #[must_use = "futures do nothing unless polled"]
12 pub struct Empty<T, E> {
13 _data: marker::PhantomData<(T, E)>,
14 }
15
16 /// Creates a future which never resolves, representing a computation that never
17 /// finishes.
18 ///
19 /// The returned future will forever return `Async::NotReady`.
empty<T, E>() -> Empty<T, E>20 pub fn empty<T, E>() -> Empty<T, E> {
21 Empty { _data: marker::PhantomData }
22 }
23
24 impl<T, E> Future for Empty<T, E> {
25 type Item = T;
26 type Error = E;
27
poll(&mut self) -> Poll<T, E>28 fn poll(&mut self) -> Poll<T, E> {
29 Ok(Async::NotReady)
30 }
31 }
32