Skip to content

Commit

Permalink
impl FusedIterator and a size hint for the error sources iter
Browse files Browse the repository at this point in the history
  • Loading branch information
Sky9x committed Jun 28, 2024
1 parent 9c3bc80 commit cc7093f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions library/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,19 @@ impl<'a> Iterator for Source<'a> {
self.current = self.current.and_then(Error::source);
current
}

fn size_hint(&self) -> (usize, Option<usize>) {
if self.current.is_some() {
(1, None)
} else {
(0, Some(0))
}
}
}

#[unstable(feature = "error_iter", issue = "58520")]
impl<'a> crate::iter::FusedIterator for Source<'a> {}

#[stable(feature = "error_by_ref", since = "1.51.0")]
impl<'a, T: Error + ?Sized> Error for &'a T {
#[allow(deprecated, deprecated_in_future)]
Expand Down

0 comments on commit cc7093f

Please sign in to comment.