Implement size_hint on the GroupBy and GroupByMut Iterators

This commit is contained in:
Clément Renault 2020-12-10 11:22:20 +01:00
parent 1c55a73b75
commit e16eaeaa11
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4

View file

@ -3009,6 +3009,15 @@ where P: FnMut(&T, &T) -> bool,
Some(head)
}
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
if self.slice.is_empty() {
(0, Some(0))
} else {
(1, Some(self.slice.len()))
}
}
}
#[unstable(feature = "slice_group_by", issue = "0")]
@ -3080,6 +3089,15 @@ where P: FnMut(&T, &T) -> bool,
Some(head)
}
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
if self.slice.is_empty() {
(0, Some(0))
} else {
(1, Some(self.slice.len()))
}
}
}
#[unstable(feature = "slice_group_by", issue = "0")]