rust-lang / rust-lang/rust

Tracking Issue for adding `partial_sort_unstable` to `[T]`

Open
#149,046 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(slice_partial_sort_unstable)]

This is a tracking issue for https://github.com/rust-lang/libs-team/issues/685.

Public API
impl<T> [T] {
  pub fn partial_sort_unstable<R>(&mut self, range: R) where T: Ord, R: RangeBounds<usize> { ... }
  pub fn partial_sort_unstable_by<F, R>(&mut self, range: R, mut compare: F) where F: FnMut(&T, &T) -> Ordering, R: RangeBounds<usize> { ... }
  pub fn partial_sort_unstable_by_key<K, F, R>(&mut self, range: R, mut f: F) where F: FnMut(&T) -> K, K: Ord, R: RangeBounds<usize>  { ... }
}

#[test]
fn demostration() {
    let mut before: Vec<u32> = vec![4, 4, 3, 3, 1, 1, 2, 2];
    let last = 6;
    let mut d = before.clone();
    d.sort();

    before.partial_sort_unstable_by(..last, |a, b| a.cmp(b));
    assert_eq!(&d[0..last], &before[0..last]);
}
Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

Unresolved Questions
  • None yet.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the feature gate slice_partial_sort_unstable and the checked implementation PR #149318, then review ACP #685 and the linked stabilization guide. The remaining work is to follow the tracking checklist through final comment period and stabilization; the issue is already under way rather than an unclaimed implementation task.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.