Add IntoError trait to convert Error kinds into Error instances

This commit is contained in:
Matthias Beyer 2016-05-16 23:51:13 +02:00
parent 6fac67b910
commit 8e0014d507
2 changed files with 15 additions and 0 deletions

14
libimagerror/src/into.rs Normal file
View file

@ -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<Error>) -> Self::Target;
}

View file

@ -1,5 +1,6 @@
#[macro_use] extern crate log;
extern crate ansi_term;
pub mod into;
pub mod error_gen;
pub mod trace;