futures_core/
never.rs

1//! Definition and trait implementations for the `Never` type,
2//! a stand-in for the `!` type until it becomes stable.
3
4use {Future, Stream, Poll};
5use task;
6
7/// A type with no possible values.
8///
9/// This is used to indicate values which can never be created, such as the
10/// error type of infallible futures.
11///
12/// This type is a stable equivalent to the `!` type from `std`.
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
14pub enum Never {}
15
16impl Never {
17    /// Convert the `Never` type into any other type.
18    pub fn never_into<T>(self) -> T {
19        match self {}
20    }
21}
22
23impl Future for Never {
24    type Item = Never;
25    type Error = Never;
26
27    fn poll(&mut self, _: &mut task::Context) -> Poll<Never, Never> {
28        match *self {}
29    }
30}
31
32impl Stream for Never {
33    type Item = Never;
34    type Error = Never;
35
36    fn poll_next(&mut self, _: &mut task::Context) -> Poll<Option<Never>, Never> {
37        match *self {}
38    }
39}