impl ExactSizeIterator for Drain

This commit is contained in:
Josh Stone
2021-07-30 16:07:38 -07:00
parent 3ada5b96c2
commit aee04824d6
2 changed files with 12 additions and 0 deletions
+6
View File
@@ -1098,6 +1098,12 @@ impl<K, V> DoubleEndedIterator for Drain<'_, K, V> {
double_ended_iterator_methods!(Bucket::key_value);
}
impl<K, V> ExactSizeIterator for Drain<'_, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}
impl<'a, K, V, S> IntoIterator for &'a IndexMap<K, V, S> {
type Item = (&'a K, &'a V);
type IntoIter = Iter<'a, K, V>;
+6
View File
@@ -786,6 +786,12 @@ impl<T> DoubleEndedIterator for Drain<'_, T> {
double_ended_iterator_methods!(Bucket::key);
}
impl<T> ExactSizeIterator for Drain<'_, T> {
fn len(&self) -> usize {
self.iter.len()
}
}
impl<'a, T, S> IntoIterator for &'a IndexSet<T, S> {
type Item = &'a T;
type IntoIter = Iter<'a, T>;