about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-07-10 00:37:11 -0400
committerGitHub <noreply@github.com>2024-07-10 00:37:11 -0400
commite71d3d5238cec45bcba55f9d82e066f36ed1a4ed (patch)
treeb27c17a5b95b11fcb2b1eba1e80709e61ee82b07
parent21a0e862342e197b6740a9c60dfde300e9308b42 (diff)
parent90cbd0bfb4dd973b69cbea9509073eba4a33f6ce (diff)
downloadrust-e71d3d5238cec45bcba55f9d82e066f36ed1a4ed.tar.gz
rust-e71d3d5238cec45bcba55f9d82e066f36ed1a4ed.zip
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
-rw-r--r--library/core/src/error.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/core/src/error.rs b/library/core/src/error.rs
index 150e4f3f318..ca8983d4cbc 100644
--- a/library/core/src/error.rs
+++ b/library/core/src/error.rs
@@ -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)]