Skip to content

Commit

Permalink
Rollup merge of rust-lang#127091 - Sky9x:fused-error-sources-iter, r=…
Browse files Browse the repository at this point in the history
…dtolnay

impl FusedIterator and a size hint for the error sources iter

cc tracking issue rust-lang#58520
  • Loading branch information
matthiaskrgr authored Jul 1, 2024
2 parents 90a2326 + cc7093f commit dde0567
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 dde0567

Please sign in to comment.