Rollup merge of #127091 - Sky9x:fused-error-sources-iter, r=dtolnay

impl FusedIterator and a size hint for the error sources iter

cc tracking issue #58520
This commit is contained in:
Jacob Pratt 2024-07-10 00:37:11 -04:00 committed by GitHub
commit e71d3d5238
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1008,7 +1008,14 @@ fn next(&mut self) -> Option<Self::Item> {
self.current = self.current.and_then(Error::source); self.current = self.current.and_then(Error::source);
current 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")] #[stable(feature = "error_by_ref", since = "1.51.0")]
impl<'a, T: Error + ?Sized> Error for &'a T { impl<'a, T: Error + ?Sized> Error for &'a T {