-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 experimental Iterator::contains #135018
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joboet (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
e1b2669
to
35193cb
Compare
This comment has been minimized.
This comment has been minimized.
35193cb
to
c3b0a98
Compare
@@ -289,6 +289,16 @@ macro_rules! iterator { | |||
false | |||
} | |||
|
|||
fn contains<Q: ?Sized>(&mut self, item: Q) -> bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this reimplemented when it uses the same code as the default impl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is to use SliceContains as a optimization later, but the trait has different trait bounds, so this requires further changes to the trait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't add an empty specialization like this, either actually specialize it or leave it out for now.
This comment has been minimized.
This comment has been minimized.
c3b0a98
to
028bb41
Compare
This comment has been minimized.
This comment has been minimized.
028bb41
to
fe28c45
Compare
This comment has been minimized.
This comment has been minimized.
fe28c45
to
204793c
Compare
@@ -2770,6 +2770,39 @@ pub trait Iterator { | |||
self.try_fold((), check(f)) == ControlFlow::Break(()) | |||
} | |||
|
|||
/// Returns `true` if the iterator contains a value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other methods
/// Returns `true` if the iterator contains a value. | |
/// Tests whether a value is contained in the iterator. |
This comment has been minimized.
This comment has been minimized.
204793c
to
ca3a6f7
Compare
There is the itertools breakage with rust analyzer and the UI tests have still been failing. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
/// on collections that have a `.contains()` or `.contains_key()` method (such as | ||
/// `HashMap` or `BtreeSet`, using those methods directly will be faster. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// on collections that have a `.contains()` or `.contains_key()` method (such as | |
/// `HashMap` or `BtreeSet`, using those methods directly will be faster. | |
/// on collections that have a `.contains()` or `.contains_key()` method (such as | |
/// `HashMap` or `BtreeSet`), using those methods directly will be faster. |
r? libs-api |
tracking issue
This is the continuation of the abandoned PR.