finchers_core/
never.rs

1use error::HttpError;
2use http::StatusCode;
3use http::header::{HeaderMap, HeaderValue};
4use std::{error, fmt};
5
6/// A type which has no possible values.
7// FIXME: replace with futures_core::Never
8#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Ord, Eq)]
9pub enum Never {}
10
11impl Never {
12    /// Consume itself and transform into an arbitrary type.
13    ///
14    /// NOTE: This function has never been actually called because the possible values don't exist.
15    pub fn never_into<T>(self) -> T {
16        match self {}
17    }
18}
19
20impl fmt::Display for Never {
21    fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
22        match *self {}
23    }
24}
25
26impl error::Error for Never {
27    fn description(&self) -> &str {
28        match *self {}
29    }
30
31    fn cause(&self) -> Option<&error::Error> {
32        match *self {}
33    }
34}
35
36impl HttpError for Never {
37    fn status_code(&self) -> StatusCode {
38        match *self {}
39    }
40
41    fn append_headers(&self, _: &mut HeaderMap<HeaderValue>) {
42        match *self {}
43    }
44}