Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 3e8a7a6

Browse files
committed
Implement From<Error> for Kind and Deref<Kind>.
1 parent e2e49c7 commit 3e8a7a6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,6 @@ macro_rules! error_chain {
364364
&self.0
365365
}
366366

367-
pub fn into_kind(self) -> $error_kind_name {
368-
self.0
369-
}
370-
371367
pub fn iter(&self) -> $crate::ErrorChainIter {
372368
$crate::ErrorChainIter(Some(self))
373369
}
@@ -444,6 +440,14 @@ macro_rules! error_chain {
444440
}
445441
}
446442

443+
impl ::std::ops::Deref for $error_name {
444+
type Target = $error_kind_name;
445+
446+
fn deref(&self) -> &Self::Target {
447+
&self.0
448+
}
449+
}
450+
447451

448452
// The ErrorKind type
449453
// --------------
@@ -498,6 +502,12 @@ macro_rules! error_chain {
498502
}
499503
}
500504

505+
impl From<$error_name> for $error_kind_name {
506+
fn from(e: $error_name) -> Self {
507+
e.0
508+
}
509+
}
510+
501511

502512
// The ChainErr trait
503513
// ------------------

0 commit comments

Comments
 (0)