-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Iterator::at_least() and Iterator::at_most() API #80835
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kennytm (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
Well, that effect could also be achieved by adding a |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #81089) made this pull request unmergeable. Please resolve the merge conflicts. |
aafcd34
to
7fb280a
Compare
This comment has been minimized.
This comment has been minimized.
0afded7
to
f1764bd
Compare
@the8472 TIL. Good point. Thanks. 😄 So I'm wondering why the implementation of |
☔ The latest upstream changes (presumably #82953) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @m-ou-se |
Triage: There's merge conflicts now. @Folyd |
@Folyd Thanks for your PR! Do you have some motivating examples? While |
Thanks, @m-ou-se. I agree with you. Let's close this. 👌 |
at_least()
andat_most()
are similar toany()
andall()
, these two methods test if at least/mostn
elements of the iterator matches a predicate.Although, we can simply use
iter.filter().count() > n
,at_least()
andat_most()
are short-circuiting, so it's more effecency than the simple filter in most cases.I have created a benchmark project to demonstrate three versions of
at_least
, here is the repository link.