Skip to content

Commit

Permalink
Merge pull request #300 from jacobtread-contrib/error-convert
Browse files Browse the repository at this point in the history
Add conversion between error types
  • Loading branch information
pksunkara committed Jan 18, 2024
2 parents 3d0ba2d + b292797 commit 3186228
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/error.rs
Expand Up @@ -12,3 +12,13 @@ pub enum Error {

/// Result type where errors are of type [Error](enum@Error).
pub type Result<T = ()> = StdResult<T, Error>;

impl From<Error> for IoError {
fn from(value: Error) -> Self {
match value {
Error::IO(err) => err,
// If other error types are added in the future:
// err => IoError::new(std::io::ErrorKind::Other, err),
}
}
}

0 comments on commit 3186228

Please sign in to comment.