impl FusedIterator and a size hint for the error sources iter

This commit is contained in:
Sky 2024-06-28 14:05:45 -04:00
parent 9c3bc805dd
commit 90cbd0bfb4
No known key found for this signature in database
GPG Key ID: EED1A7AF86ACBCEF

View File

@ -1008,8 +1008,15 @@ 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 {
#[allow(deprecated, deprecated_in_future)] #[allow(deprecated, deprecated_in_future)]