-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 the partition_point feature #81012
Conversation
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
@rust-lang/libs This method finds the start of the range of elements where pred=false, assuming all elements for which pred=true come before all elements for which pred=false, via binary search. impl<T> [T] {
pub fn partition_point<P>(&self, pred: P) -> usize
where
P: FnMut(&T) -> bool;
} This is a special case of binary_search_by, but reasonably common and not all that clear expressed using binary_search_by. slice.partition_point(pred)
// equivalent to
slice.binary_search_by(|x| if pred(x) { Less } else { Greater }).unwrap_err() The polarity choice for whether false or true elements go first is consistent with the stable Iterator::partition (https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.partition), with STL's std::partition_point in C++ (https://en.cppreference.com/w/cpp/algorithm/partition_point), and with the unstable Iterator::is_partitioned (#62544, https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.is_partitioned). |
This comment has been minimized.
This comment has been minimized.
We recently decided to do FCPs on the tracking issue instead of a stabilization PR if possible, to avoid splitting the discussion to two places. (Our new library tracking issue template reflects this.) There's valuable information in the discussion on the tracking issue, and it'd be good to keep that together with any discussion that follows now we're going for stabilization. So I'm moving the FCP to that issue, and close this for now. Please feel free to re-open this PR once stabilization is decided upon in the tracking issue. Thanks! @rfcbot cancel |
@m-ou-se proposal cancelled. |
@VillSnow Sorry for the confusion about the library stabilization process. The new info is in the new tracking issue template, but we should really fix the documentation too. ^^' |
Yay, FCP on the tracking issue completed, this can be reopened. I think we also want to change |
Yup, the version bump to 1.52 already happened last week: https://github.com/rust-lang/rust/blob/master/src/version |
This comment has been minimized.
This comment has been minimized.
@VillSnow Can you rebase/squash the commits? We generally try to avoid merge commits on branches/PRs. |
Yes, Can you also squash the commits? |
Is it means six commits 'stabilize partition_points' to 'update feature gate' into single commit like 'stabilize partition_points' ? |
Both are fine. Whatever you prefer :) |
9da8f50
to
afdc8c7
Compare
based on #73831 (comment) @bors r+ |
📌 Commit afdc8c7 has been approved by |
Rollup of 10 pull requests Successful merges: - rust-lang#79775 (Fix injected errors when running doctests on a crate named after a keyword) - rust-lang#81012 (Stabilize the partition_point feature) - rust-lang#81479 (Allow casting mut array ref to mut ptr) - rust-lang#81506 (HWAddressSanitizer support) - rust-lang#81741 (Increment `self.index` before calling `Iterator::self.a.__iterator_ge…) - rust-lang#81850 (use RWlock when accessing os::env) - rust-lang#81911 (GAT/const_generics: Allow with_opt_const_param to return GAT param def_id) - rust-lang#82022 (Push a `char` instead of a `str` with len one into a String) - rust-lang#82023 (Remove unnecessary lint allow attrs on example) - rust-lang#82030 (Use `Iterator::all` instead of open-coding it) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Stabilize the partition_point feature.
Tracking Issue: #73831
First PR: #73577