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 1
1
# Unreleased
2
2
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 )
3
5
- [ Implement ` Debug ` for ` ErrorChainIter ` ] ( https://github.com/brson/error-chain/issues/169 )
4
6
- [ Rename ` ChainedError::display ` to ` display_chain ` ] ( https://github.com/brson/error-chain/issues/180 )
5
7
- [ 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 {
96
96
self . kind( )
97
97
}
98
98
99
- fn iter( & self ) -> $crate:: ErrorChainIter {
100
- $crate:: ErrorChainIter ( Some ( self ) )
99
+ fn iter( & self ) -> $crate:: Iter {
100
+ $crate:: Iter :: new ( Some ( self ) )
101
101
}
102
102
103
103
fn chain_err<F , EK >( self , error: F ) -> Self
@@ -151,7 +151,7 @@ macro_rules! error_chain_processed {
151
151
}
152
152
153
153
/// Iterates over the error chain.
154
- pub fn iter( & self ) -> $crate:: ErrorChainIter {
154
+ pub fn iter( & self ) -> $crate:: Iter {
155
155
$crate:: ChainedError :: iter( self )
156
156
}
157
157
Original file line number Diff line number Diff line change @@ -495,9 +495,16 @@ pub mod example_generated;
495
495
496
496
#[ derive( Debug ) ]
497
497
/// 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 > ) ;
499
499
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 > {
501
508
type Item = & ' a error:: Error ;
502
509
503
510
fn next < ' b > ( & ' b mut self ) -> Option < & ' a error:: Error > {
@@ -542,7 +549,7 @@ pub trait ChainedError: error::Error + Send + 'static {
542
549
fn kind ( & self ) -> & Self :: ErrorKind ;
543
550
544
551
/// Iterates over the error chain.
545
- fn iter ( & self ) -> ErrorChainIter ;
552
+ fn iter ( & self ) -> Iter ;
546
553
547
554
/// Returns the backtrace associated with this error.
548
555
fn backtrace ( & self ) -> Option < & Backtrace > ;
You can’t perform that action at this time.
0 commit comments