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
use crateParseError;
/// An alias to a Result where:
///
/// * `Ok` is `T`.
/// * `Err` is a `ParseError` with context `C` and error `E`
///
/// For a `Result` that is parameterized only by the input type, see
/// [`input::Result`](crate::input::Result).
pub type Result<T, C, E> = Result;
// // This one will result in inference issues when `Ok(T)` is returned.
// impl<T, I: Input, E: ::std::fmt::Display> AsResult<T, I> for ::std::result::Result<T, E> {
// fn as_result(self) -> Result<T, I> {
// let name = unsafe { ::std::intrinsics::type_name::<E>() };
// self.map_err(|e| ParseError::new(name, e.to_string()))
// }
// }
// // This one won't but makes some things uglier to write.
// impl<T, I: Input, E2, E1: Into<E2>> AsResult<T, I, E2> for Result<T, I, E1> {
// fn as_result(self) -> Result<T, I, E2> {
// match self {
// Ok(v) => Ok(v),
// Err(e) => Err(ParseError {
// error: e.error.into(),
// contexts: e.contexts
// })
// }
// }
// }
// // This one won't but makes some things uglier to write.
// impl<T, I: Input, E> AsResult<T, I, B> for Result<T, I, A> {
// fn as_result(self) -> Result<T, I, B> {
// self
// }
// }