sel4_root_task/
termination.rs
1use core::fmt;
8
9pub trait Termination {
11 type Error: fmt::Debug;
12
13 fn report(self) -> Self::Error;
14}
15
16impl Termination for ! {
17 type Error = !;
18
19 fn report(self) -> Self::Error {
20 self
21 }
22}
23
24impl Termination for Never {
25 type Error = Never;
26
27 fn report(self) -> Self::Error {
28 self
29 }
30}
31
32impl<E: fmt::Debug> Termination for Result<!, E> {
33 type Error = E;
34
35 fn report(self) -> Self::Error {
36 match self {
37 #[allow(unreachable_patterns)]
38 Ok(absurdity) => match absurdity {},
39 Err(err) => err,
40 }
41 }
42}
43
44impl<E: fmt::Debug> Termination for Result<Never, E> {
45 type Error = E;
46
47 fn report(self) -> Self::Error {
48 match self {
49 #[allow(unreachable_patterns)]
50 Ok(absurdity) => match absurdity {},
51 Err(err) => err,
52 }
53 }
54}
55
56#[derive(Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq, Hash)]
62pub enum Never {}
63
64impl fmt::Display for Never {
65 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
66 match *self {}
67 }
68}