From 468a90e5ffe9e8cf837ef0c7df63d61171b18823 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 8 Sep 2022 11:23:52 -0700 Subject: [PATCH] feat(cordyceps): add `FusedIterator` impls for `List` iterators This enables additional optimizations if these iterators are guaranteed to never return `Some` again after returning `None` once, which they are. --- cordyceps/src/list.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cordyceps/src/list.rs b/cordyceps/src/list.rs index ad2c4da9..e2d56e79 100644 --- a/cordyceps/src/list.rs +++ b/cordyceps/src/list.rs @@ -1247,6 +1247,8 @@ impl<'list, T: Linked> + ?Sized> DoubleEndedIterator for Iter<'list, T> } } +impl<'list, T: Linked> + ?Sized> iter::FusedIterator for Iter<'list, T> {} + // === impl IterMut ==== impl<'list, T: Linked> + ?Sized> Iterator for IterMut<'list, T> { @@ -1314,6 +1316,8 @@ impl<'list, T: Linked> + ?Sized> DoubleEndedIterator for IterMut<'list, } } +impl<'list, T: Linked> + ?Sized> iter::FusedIterator for IterMut<'list, T> {} + // === impl IntoIter === impl> + ?Sized> fmt::Debug for IntoIter { @@ -1350,6 +1354,8 @@ impl> + ?Sized> ExactSizeIterator for IntoIter { } } +impl> + ?Sized> iter::FusedIterator for IntoIter {} + // === impl DrainFilter === impl Iterator for DrainFilter<'_, T, F>