Skip to content
/ rust Public
forked from rust-lang/rust

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 Jul 5, 2024
1 parent 9c3bc80 commit 90cbd0b
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 90cbd0b

Please sign in to comment.