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
70
71
72
73
74
75
76
77
78
79
#![deny(rust_2018_idioms)]
#![warn(missing_docs)]
#![warn(clippy::missing_inline_in_public_items)]
use pahs::Progress;
pub trait ProgressSnafuExt<P, T, E> {
fn snafu<C, F, E2>(self, context_fn: F) -> Progress<P, T, E2>
where
P: Clone,
C: snafu::IntoError<E2, Source = E>,
F: FnOnce(P) -> C,
E2: std::error::Error + snafu::ErrorCompat;
fn into_snafu_leaf<C, F, E2>(self, context_fn: F) -> Progress<P, T, E2>
where
P: Clone,
C: snafu::IntoError<E2, Source = snafu::NoneError>,
F: FnOnce(E, P) -> C,
E2: std::error::Error + snafu::ErrorCompat;
fn snafu_leaf<C, F, E2>(self, context_fn: F) -> Progress<P, T, E2>
where
P: Clone,
C: snafu::IntoError<E2, Source = snafu::NoneError>,
F: FnOnce(P) -> C,
E2: std::error::Error + snafu::ErrorCompat;
}
impl<P, T, E> ProgressSnafuExt<P, T, E> for Progress<P, T, E> {
#[inline]
fn snafu<C, F, E2>(self, context_fn: F) -> Progress<P, T, E2>
where
P: Clone,
C: snafu::IntoError<E2, Source = E>,
F: FnOnce(P) -> C,
E2: std::error::Error + snafu::ErrorCompat,
{
self.map_err_with_pos(|e, pos| context_fn(pos).into_error(e))
}
#[inline]
fn into_snafu_leaf<C, F, E2>(self, context_fn: F) -> Progress<P, T, E2>
where
P: Clone,
C: snafu::IntoError<E2, Source = snafu::NoneError>,
F: FnOnce(E, P) -> C,
E2: std::error::Error + snafu::ErrorCompat,
{
self.map_err_with_pos(|e, pos| context_fn(e, pos).into_error(snafu::NoneError))
}
#[inline]
fn snafu_leaf<C, F, E2>(self, context_fn: F) -> Progress<P, T, E2>
where
P: Clone,
C: snafu::IntoError<E2, Source = snafu::NoneError>,
F: FnOnce(P) -> C,
E2: std::error::Error + snafu::ErrorCompat,
{
self.map_err_with_pos(|_, pos| context_fn(pos).into_error(snafu::NoneError))
}
}