diff --git a/libimagerror/src/into.rs b/libimagerror/src/into.rs new file mode 100644 index 00000000..a959abd4 --- /dev/null +++ b/libimagerror/src/into.rs @@ -0,0 +1,14 @@ +use std::error::Error; + +/// Trait to help converting Error kinds into Error instances +pub trait IntoError { + type Target: Error; + + /// Convert the type into an error with no cause + fn into_error(self) -> Self::Target; + + /// Convert the type into an error with cause + fn into_error_with_cause(self, cause: Box) -> Self::Target; + +} + diff --git a/libimagerror/src/lib.rs b/libimagerror/src/lib.rs index d7f374a7..1d1f75e2 100644 --- a/libimagerror/src/lib.rs +++ b/libimagerror/src/lib.rs @@ -1,5 +1,6 @@ #[macro_use] extern crate log; extern crate ansi_term; +pub mod into; pub mod error_gen; pub mod trace;