Skip to content

Commit 90cbd0b

Browse files
committed
impl FusedIterator and a size hint for the error sources iter
1 parent 9c3bc80 commit 90cbd0b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

library/core/src/error.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,15 @@ impl<'a> Iterator for Source<'a> {
10081008
self.current = self.current.and_then(Error::source);
10091009
current
10101010
}
1011+
1012+
fn size_hint(&self) -> (usize, Option<usize>) {
1013+
if self.current.is_some() { (1, None) } else { (0, Some(0)) }
1014+
}
10111015
}
10121016

1017+
#[unstable(feature = "error_iter", issue = "58520")]
1018+
impl<'a> crate::iter::FusedIterator for Source<'a> {}
1019+
10131020
#[stable(feature = "error_by_ref", since = "1.51.0")]
10141021
impl<'a, T: Error + ?Sized> Error for &'a T {
10151022
#[allow(deprecated, deprecated_in_future)]

0 commit comments

Comments
 (0)