Implement size_hint on the GroupBy and GroupByMut Iterators
This commit is contained in:
parent
1c55a73b75
commit
e16eaeaa11
1 changed files with 18 additions and 0 deletions
|
|
@ -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")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue