-
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
Stabilize partition_in_place #76505
Stabilize partition_in_place #76505
Conversation
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
To copy an open question from the tracking issue:
|
☔ The latest upstream changes (presumably #77381) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@rust-lang/libs: This PR stabilizes https://doc.rust-lang.org/1.47.0/std/iter/trait.Iterator.html#method.partition_in_place. pub trait Iterator {
...
fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
where
Self: Sized + DoubleEndedIterator<Item = &'a mut T>,
P: FnMut(&T) -> bool,
T: 'a {/*...*/}
} Some design questions from the tracking issue:
@rfcbot fcp merge |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot concern should-this-be-an-iter-method I'm vaguely concerned about the precedent set by this API addition, and I'd like to see more justification for it. It's a very strange and novel addition actually because of how it uses iterator, and I don't really see any big discussion of this.
|
Alexander Stepanov, author of the partition functions in the C++ STL, considers it to have been a mistake to place the elements that satisfy the predicate at the start, rather than at the end. See page 167 of his Notes on Programming at http://stepanovpapers.com/notes.pdf. Should we consider "fixing" this? |
I think it falls in the category of "simple, but hard" that's good for My motivation was to match the C++
Any iterator with
Any ordered collection with mutable iterators would apply. It's more questionable whether it makes sense to be swapping items around. Yes for slices, It could be a method for slices instead, but I think that restriction is only useful if it helps the implementation. Maybe that would make a stable variant feasible, but I haven't given that algorithm much thought.
I think there's value in keeping that precedent as a point of consistency for C++ defectors. We also have some precedent of our own in that |
This PR was discussed in the libs team meeting of 2020-11-18. The consensus was that functions for algorithms like this should probably not be part of |
That does exist as |
☔ The latest upstream changes (presumably #80530) made this pull request unmergeable. Please resolve the merge conflicts. |
@rfcbot cancel |
@m-ou-se proposal cancelled. |
@slo1 Ping from triage, according to previous discussions. Would you like to help change the forementioned method into free functions? Thanks! |
Oh whoops, I'm a beginner so a lot of the discussion went over my head. I didn't realize there was something actionable to do. When you say free functions, do you mean point free functions? |
@slo1 The conclusion was that we'd probably not want functions like this directly on the If you want to work towards that or discuss the stabilization of this feature more, you're very welcome to do so. But for now, I'm closing this PR and directing the discussion back to the tracking issue: #62543 Thanks! |
Closes #62543