From e26c8818397a9de0a9a51b35eb574a95f37be8c1 Mon Sep 17 00:00:00 2001 From: Sky Date: Fri, 28 Jun 2024 14:05:45 -0400 Subject: [PATCH] impl FusedIterator and a size hint for the error sources iter --- core/src/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/error.rs b/core/src/error.rs index 150e4f3f31857..ca8983d4cbcfe 100644 --- a/core/src/error.rs +++ b/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) { + 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)]