Skip to content

Commit e16eaea

Browse files
committed
Implement size_hint on the GroupBy and GroupByMut Iterators
1 parent 1c55a73 commit e16eaea

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

library/core/src/slice/iter.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,6 +3009,15 @@ where P: FnMut(&T, &T) -> bool,
30093009
Some(head)
30103010
}
30113011
}
3012+
3013+
#[inline]
3014+
fn size_hint(&self) -> (usize, Option<usize>) {
3015+
if self.slice.is_empty() {
3016+
(0, Some(0))
3017+
} else {
3018+
(1, Some(self.slice.len()))
3019+
}
3020+
}
30123021
}
30133022

30143023
#[unstable(feature = "slice_group_by", issue = "0")]
@@ -3080,6 +3089,15 @@ where P: FnMut(&T, &T) -> bool,
30803089
Some(head)
30813090
}
30823091
}
3092+
3093+
#[inline]
3094+
fn size_hint(&self) -> (usize, Option<usize>) {
3095+
if self.slice.is_empty() {
3096+
(0, Some(0))
3097+
} else {
3098+
(1, Some(self.slice.len()))
3099+
}
3100+
}
30833101
}
30843102

30853103
#[unstable(feature = "slice_group_by", issue = "0")]

0 commit comments

Comments
 (0)