Implement IntoError for all generated Errors automatically

This commit is contained in:
Matthias Beyer 2016-05-16 23:51:26 +02:00
parent 8e0014d507
commit 3845f28dad

View file

@ -1,3 +1,5 @@
use into::IntoError;
#[macro_export]
macro_rules! generate_error_imports {
() => {
@ -41,6 +43,19 @@ macro_rules! generate_error_types {
}
impl IntoError for $kindname {
type Target = $name;
fn into_error(self) -> Self::Target {
$name::new(self, None)
}
fn into_error_with_cause(self, cause: Box<Error>) -> Self::Target {
$name::new(self, Some(cause))
}
}
#[derive(Debug)]
pub struct $name {
err_type: $kindname,