Skip to content

Commit 3186228

Browse files
authored
Merge pull request #300 from jacobtread-contrib/error-convert
Add conversion between error types
2 parents 3d0ba2d + b292797 commit 3186228

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/error.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,13 @@ pub enum Error {
1212

1313
/// Result type where errors are of type [Error](enum@Error).
1414
pub type Result<T = ()> = StdResult<T, Error>;
15+
16+
impl From<Error> for IoError {
17+
fn from(value: Error) -> Self {
18+
match value {
19+
Error::IO(err) => err,
20+
// If other error types are added in the future:
21+
// err => IoError::new(std::io::ErrorKind::Other, err),
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)