Fri, 13 Oct 2023 13:32:15 -0500
Update Cargo.lock to stop build failures with current nightly rust.
5 | 1 | /*! |
2 | Error passing helper types | |
3 | */ | |
0 | 4 | |
5 | use std::error::Error; | |
6 | ||
5 | 7 | /// A [`Result`] containing `T` or a dynamic error type |
0 | 8 | pub type DynResult<T> = Result<T, Box<dyn Error>>; |
5 | 9 | |
10 | /// A [`Result`] containing `()` or a dynamic error type | |
0 | 11 | pub type DynError = DynResult<()>; |
12 | ||
4
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
13 | #[derive(Clone, Debug)] |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
14 | /// Type for numerical errors. |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
15 | pub struct NumericalError( |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
16 | /// Provides additional information about the error |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
17 | pub &'static str |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
18 | ); |
0 | 19 | |
4
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
20 | impl std::fmt::Display for NumericalError { |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
21 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
22 | match self.0 { |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
23 | "" => write!(f, "Numerical error"), |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
24 | s => write!(f, "{s}"), |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
25 | } |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
26 | } |
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
27 | } |
0 | 28 | |
4
61b068c50e25
Added type for numerical errors
Tuomo Valkonen <tuomov@iki.fi>
parents:
0
diff
changeset
|
29 | impl std::error::Error for NumericalError {} |