diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index b83c4d89c1e..fc27b6a67bf 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -2233,6 +2233,10 @@ impl<'a, K, V> Iterator for Iter<'a, K, V> { self.base.size_hint() } #[inline] + fn count(self) -> usize { + self.base.len() + } + #[inline] fn fold(self, init: B, f: F) -> B where Self: Sized, @@ -2265,6 +2269,10 @@ impl<'a, K, V> Iterator for IterMut<'a, K, V> { self.base.size_hint() } #[inline] + fn count(self) -> usize { + self.base.len() + } + #[inline] fn fold(self, init: B, f: F) -> B where Self: Sized, @@ -2307,6 +2315,10 @@ impl Iterator for IntoIter { self.base.size_hint() } #[inline] + fn count(self) -> usize { + self.base.len() + } + #[inline] fn fold(self, init: B, f: F) -> B where Self: Sized, @@ -2345,6 +2357,10 @@ impl<'a, K, V> Iterator for Keys<'a, K, V> { self.inner.size_hint() } #[inline] + fn count(self) -> usize { + self.inner.len() + } + #[inline] fn fold(self, init: B, mut f: F) -> B where Self: Sized, @@ -2376,6 +2392,10 @@ impl<'a, K, V> Iterator for Values<'a, K, V> { self.inner.size_hint() } #[inline] + fn count(self) -> usize { + self.inner.len() + } + #[inline] fn fold(self, init: B, mut f: F) -> B where Self: Sized, @@ -2407,6 +2427,10 @@ impl<'a, K, V> Iterator for ValuesMut<'a, K, V> { self.inner.size_hint() } #[inline] + fn count(self) -> usize { + self.inner.len() + } + #[inline] fn fold(self, init: B, mut f: F) -> B where Self: Sized, @@ -2445,6 +2469,10 @@ impl Iterator for IntoKeys { self.inner.size_hint() } #[inline] + fn count(self) -> usize { + self.inner.len() + } + #[inline] fn fold(self, init: B, mut f: F) -> B where Self: Sized, @@ -2483,6 +2511,10 @@ impl Iterator for IntoValues { self.inner.size_hint() } #[inline] + fn count(self) -> usize { + self.inner.len() + } + #[inline] fn fold(self, init: B, mut f: F) -> B where Self: Sized, diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index ea9239f0c47..dcb2fa0f771 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -1501,6 +1501,10 @@ impl<'a, K> Iterator for Iter<'a, K> { self.base.size_hint() } #[inline] + fn count(self) -> usize { + self.base.len() + } + #[inline] fn fold(self, init: B, f: F) -> B where Self: Sized, @@ -1539,6 +1543,10 @@ impl Iterator for IntoIter { self.base.size_hint() } #[inline] + fn count(self) -> usize { + self.base.len() + } + #[inline] fn fold(self, init: B, f: F) -> B where Self: Sized, @@ -1851,6 +1859,10 @@ where self.iter.size_hint() } #[inline] + fn count(self) -> usize { + self.iter.count() + } + #[inline] fn fold(self, init: B, f: F) -> B where Self: Sized,