1use crate::{imp::Marker, outcome::Sealed, IexPanic, Outcome, EXCEPTION};
2
3impl<T, E> Sealed for Result<T, E> {}
4
5impl<T, E> Outcome for Result<T, E> {
6 type Output = T;
7
8 type Error = E;
9
10 fn get_value_or_panic(self, _marker: Marker<E>) -> T {
11 self.unwrap_or_else(|error| {
12 EXCEPTION.with(|exception| unsafe { &mut *exception.get() }.write(error));
13 std::panic::resume_unwind(Box::new(IexPanic))
15 })
16 }
17
18 #[cfg(doc)]
19 #[crate::iex]
20 fn inspect_err<F>(self, f: F) -> Result<T, E>
21 where
22 F: FnOnce(&Self::Error),
23 {
24 }
25
26 #[cfg(not(doc))]
27 fn inspect_err<F>(self, f: F) -> impl Outcome<Output = T, Error = E>
28 where
29 F: FnOnce(&Self::Error),
30 {
31 Result::inspect_err(self, f)
32 }
33
34 #[cfg(doc)]
35 #[crate::iex]
36 fn map_err<F, O>(self, op: O) -> Result<T, F>
37 where
38 O: FnOnce(E) -> F,
39 {
40 }
41
42 #[cfg(not(doc))]
43 fn map_err<F, O>(self, op: O) -> impl Outcome<Output = Self::Output, Error = F>
44 where
45 O: FnOnce(E) -> F,
46 {
47 Result::map_err(self, op)
48 }
49
50 fn into_result(self) -> Self {
51 self
52 }
53}