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 9, 2024
2 parents 9dcaa7f + 90cbd0b commit 06b4170
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,8 +1008,15 @@ 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 06b4170

Please sign in to comment.