1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#[cfg(any(feature = "std", test))]
use std_::fmt;
use super::ResultLike;
use type_identity::TypeIdentity;
#[allow(unused_imports)]
use SelfOps;
pub trait ResultExt<T, E>: Sized + ResultLike + TypeIdentity<Type = Result<T, E>> {
#[cfg(any(feature = "std", test))]
#[inline]
fn format_debug_err(self) -> Result<T, String>
where
E: fmt::Debug,
{
self.into_type_val().map_err(|e| format!("{:?}", e))
}
#[cfg(any(feature = "std", test))]
fn format_alt_debug_err(self) -> Result<T, String>
where
E: fmt::Debug,
{
self.into_type_val().map_err(|e| format!("{:#?}", e))
}
}
impl<E, T> ResultExt<T, E> for Result<T, E> {}
impl<E, T> ResultLike for Result<T, E> {
type Item = T;
type Error = E;
#[inline]
fn is_item(&self) -> bool {
self.is_ok()
}
#[inline]
fn to_result_(self) -> Result<Self::Item, Self::Error> {
self
}
}