diff --git a/src/chain.rs b/src/chain.rs new file mode 100644 index 0000000..78f824f --- /dev/null +++ b/src/chain.rs @@ -0,0 +1,12 @@ +use crate::Chain; +use std::error::Error as StdError; + +impl<'a> Iterator for Chain<'a> { + type Item = &'a (dyn StdError + 'static); + + fn next(&mut self) -> Option { + let next = self.next?; + self.next = next.source(); + Some(next) + } +} diff --git a/src/error.rs b/src/error.rs index f51033e..2953b2b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -726,13 +726,3 @@ impl From for Box { Box::::from(error) } } - -impl<'a> Iterator for Chain<'a> { - type Item = &'a (dyn StdError + 'static); - - fn next(&mut self) -> Option { - let next = self.next?; - self.next = next.source(); - Some(next) - } -} diff --git a/src/lib.rs b/src/lib.rs index ab552ec..ad0aa08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,6 +169,7 @@ #[macro_use] mod backtrace; +mod chain; mod context; mod error; mod fmt;