This repository was archived by the owner on Aug 16, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Expand file tree Collapse file tree 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 11# Unreleased
22
3+ - [ Make ` ErrorChainIter ` 's field private] ( https://github.com/brson/error-chain/issues/178 )
4+ - [ Rename ` ErrorChainIter ` to ` Iter ` ] ( https://github.com/brson/error-chain/issues/168 )
35- [ Implement ` Debug ` for ` ErrorChainIter ` ] ( https://github.com/brson/error-chain/issues/169 )
46- [ Rename ` ChainedError::display ` to ` display_chain ` ] ( https://github.com/brson/error-chain/issues/180 )
57- [ Add a new method for ` Error ` : ` chain_err ` .] ( https://github.com/brson/error-chain/pull/141 )
Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ macro_rules! error_chain_processed {
9696 self . kind( )
9797 }
9898
99- fn iter( & self ) -> $crate:: ErrorChainIter {
100- $crate:: ErrorChainIter ( Some ( self ) )
99+ fn iter( & self ) -> $crate:: Iter {
100+ $crate:: Iter :: new ( Some ( self ) )
101101 }
102102
103103 fn chain_err<F , EK >( self , error: F ) -> Self
@@ -151,7 +151,7 @@ macro_rules! error_chain_processed {
151151 }
152152
153153 /// Iterates over the error chain.
154- pub fn iter( & self ) -> $crate:: ErrorChainIter {
154+ pub fn iter( & self ) -> $crate:: Iter {
155155 $crate:: ChainedError :: iter( self )
156156 }
157157
Original file line number Diff line number Diff line change @@ -495,9 +495,16 @@ pub mod example_generated;
495495
496496#[ derive( Debug ) ]
497497/// Iterator over the error chain using the `Error::cause()` method.
498- pub struct ErrorChainIter < ' a > ( pub Option < & ' a error:: Error > ) ;
498+ pub struct Iter < ' a > ( Option < & ' a error:: Error > ) ;
499499
500- impl < ' a > Iterator for ErrorChainIter < ' a > {
500+ impl < ' a > Iter < ' a > {
501+ /// Returns a new iterator over the error chain using `Error::cause()`.
502+ pub fn new ( err : Option < & ' a error:: Error > ) -> Iter < ' a > {
503+ Iter ( err)
504+ }
505+ }
506+
507+ impl < ' a > Iterator for Iter < ' a > {
501508 type Item = & ' a error:: Error ;
502509
503510 fn next < ' b > ( & ' b mut self ) -> Option < & ' a error:: Error > {
@@ -542,7 +549,7 @@ pub trait ChainedError: error::Error + Send + 'static {
542549 fn kind ( & self ) -> & Self :: ErrorKind ;
543550
544551 /// Iterates over the error chain.
545- fn iter ( & self ) -> ErrorChainIter ;
552+ fn iter ( & self ) -> Iter ;
546553
547554 /// Returns the backtrace associated with this error.
548555 fn backtrace ( & self ) -> Option < & Backtrace > ;
You can’t perform that action at this time.
0 commit comments