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 slice_sort_by_cached_key #58074

Merged
merged 2 commits into from Feb 17, 2019

Conversation

Projects
None yet
8 participants
@scottmcm
Copy link
Member

scottmcm commented Feb 2, 2019

I was going to ask on the tracking issue (#34447), but decided to just send this and hope for an FCP here. The method was added last March by #48639.

Signature: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_cached_key

impl [T] {
    pub fn sort_by_cached_key<K, F>(&mut self, f: F)
        where F: FnMut(&T) -> K, K: Ord;
}

That's an identical signature to the existing sort_by_key, so I think the questions are just naming, implementation, and the usual "do we want this?".

The implementation seems to have proven its use in rustc at least, which many uses: https://github.com/rust-lang/rust/search?l=Rust&q=sort_by_cached_key

(I'm asking because it's exactly what I just needed the other day:

    all_positions.sort_by_cached_key(|&n|
        data::CITIES.iter()
            .map(|x| *metric_closure.get_edge(n, x.pos).unwrap())
            .sum::<usize>()
    );

since caching that key is a pretty obviously good idea.)

Closes #34447

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Feb 2, 2019

r? @Mark-Simulacrum

(rust_highfive has picked a reviewer for you, use r? to override)

@scottmcm

This comment has been minimized.

Copy link
Member Author

scottmcm commented Feb 2, 2019

Since this is needs-fcp, it needs someone from libs. Since they've p-FCP'd things recently, how about

r? @SimonSapin

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Feb 2, 2019

@rfcbot fcp merge

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 2, 2019

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and none object), 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.

@SimonSapin

This comment has been minimized.

Copy link
Contributor

SimonSapin commented Feb 2, 2019

r+ on the diff, good to merge once FCP is finished.

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 5, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Feb 13, 2019

☔️ The latest upstream changes (presumably #58051) made this pull request unmergeable. Please resolve the merge conflicts.

@scottmcm scottmcm force-pushed the scottmcm:stabilize-sort_by_cached_key branch from 2827922 to 317f153 Feb 13, 2019

@rfcbot

This comment has been minimized.

Copy link

rfcbot commented Feb 15, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

@scottmcm

This comment has been minimized.

Copy link
Member Author

scottmcm commented Feb 15, 2019

@bors r=SimonSapin

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 15, 2019

📌 Commit 317f153 has been approved by SimonSapin

kennytm added a commit to kennytm/rust that referenced this pull request Feb 15, 2019

Rollup merge of rust-lang#58074 - scottmcm:stabilize-sort_by_cached_k…
…ey, r=SimonSapin

Stabilize slice_sort_by_cached_key

I was going to ask on the tracking issue (rust-lang#34447), but decided to just send this and hope for an FCP here.  The method was added last March by rust-lang#48639.

Signature: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_cached_key
```rust
impl [T] {
    pub fn sort_by_cached_key<K, F>(&mut self, f: F)
        where F: FnMut(&T) -> K, K: Ord;
}
```

That's an identical signature to the existing `sort_by_key`, so I think the questions are just naming, implementation, and the usual "do we want this?".

The implementation seems to have proven its use in rustc at least, which many uses: https://github.com/rust-lang/rust/search?l=Rust&q=sort_by_cached_key

(I'm asking because it's exactly what I just needed the other day:
```rust
    all_positions.sort_by_cached_key(|&n|
        data::CITIES.iter()
            .map(|x| *metric_closure.get_edge(n, x.pos).unwrap())
            .sum::<usize>()
    );
```
since caching that key is a pretty obviously good idea.)

Closes rust-lang#34447

bors added a commit that referenced this pull request Feb 15, 2019

Auto merge of #58495 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests

Successful merges:

 - #57880 (Always emit an error for a query cycle)
 - #57981 (Fix #57730)
 - #58074 (Stabilize slice_sort_by_cached_key)
 - #58196 (Add specific feature gate error for const-unstable features)
 - #58293 (Remove code for updating copyright years in generate-deriving-span-tests)
 - #58306 (Don't default on std crate when manipulating browser history)
 - #58359 (librustc_mir: use ? in impl_snapshot_for! macro)
 - #58429 (fix Box::into_unique effecitvely transmuting to a raw ptr)
 - #58433 (Update which libcore/liballoc tests Miri ignores, and document why)
 - #58438 (Use posix_spawn_file_actions_addchdir_np when possible)
 - #58440 (Whitelist the ARM v6 target-feature)
 - #58448 (rustdoc: mask `compiler_builtins` docs)
 - #58468 (split MaybeUninit into several features, expand docs a bit)
 - #58477 (Fix the syntax error in publish_toolstate.py)
 - #58479 (compile-pass test for #53606)
 - #58489 (Fix runtime error in generate-keyword-tests)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 15, 2019

⌛️ Testing commit 317f153 with merge 8bfe6ce...

bors added a commit that referenced this pull request Feb 15, 2019

Auto merge of #58074 - scottmcm:stabilize-sort_by_cached_key, r=Simon…
…Sapin

Stabilize slice_sort_by_cached_key

I was going to ask on the tracking issue (#34447), but decided to just send this and hope for an FCP here.  The method was added last March by #48639.

Signature: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_cached_key
```rust
impl [T] {
    pub fn sort_by_cached_key<K, F>(&mut self, f: F)
        where F: FnMut(&T) -> K, K: Ord;
}
```

That's an identical signature to the existing `sort_by_key`, so I think the questions are just naming, implementation, and the usual "do we want this?".

The implementation seems to have proven its use in rustc at least, which many uses: https://github.com/rust-lang/rust/search?l=Rust&q=sort_by_cached_key

(I'm asking because it's exactly what I just needed the other day:
```rust
    all_positions.sort_by_cached_key(|&n|
        data::CITIES.iter()
            .map(|x| *metric_closure.get_edge(n, x.pos).unwrap())
            .sum::<usize>()
    );
```
since caching that key is a pretty obviously good idea.)

Closes #34447
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 15, 2019

💔 Test failed - checks-travis

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 15, 2019

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented Feb 15, 2019

@bors retry -- apparently we can't clone the repo anymore on macOS

bors added a commit that referenced this pull request Feb 15, 2019

Auto merge of #58495 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests

Successful merges:

 - #57880 (Always emit an error for a query cycle)
 - #57981 (Fix #57730)
 - #58074 (Stabilize slice_sort_by_cached_key)
 - #58196 (Add specific feature gate error for const-unstable features)
 - #58293 (Remove code for updating copyright years in generate-deriving-span-tests)
 - #58306 (Don't default on std crate when manipulating browser history)
 - #58359 (librustc_mir: use ? in impl_snapshot_for! macro)
 - #58429 (fix Box::into_unique effecitvely transmuting to a raw ptr)
 - #58433 (Update which libcore/liballoc tests Miri ignores, and document why)
 - #58438 (Use posix_spawn_file_actions_addchdir_np when possible)
 - #58440 (Whitelist the ARM v6 target-feature)
 - #58448 (rustdoc: mask `compiler_builtins` docs)
 - #58468 (split MaybeUninit into several features, expand docs a bit)
 - #58477 (Fix the syntax error in publish_toolstate.py)
 - #58479 (compile-pass test for #53606)
 - #58489 (Fix runtime error in generate-keyword-tests)

Failed merges:

r? @ghost

kennytm added a commit to kennytm/rust that referenced this pull request Feb 16, 2019

Rollup merge of rust-lang#58074 - scottmcm:stabilize-sort_by_cached_k…
…ey, r=SimonSapin

Stabilize slice_sort_by_cached_key

I was going to ask on the tracking issue (rust-lang#34447), but decided to just send this and hope for an FCP here.  The method was added last March by rust-lang#48639.

Signature: https://doc.rust-lang.org/std/primitive.slice.html#method.sort_by_cached_key
```rust
impl [T] {
    pub fn sort_by_cached_key<K, F>(&mut self, f: F)
        where F: FnMut(&T) -> K, K: Ord;
}
```

That's an identical signature to the existing `sort_by_key`, so I think the questions are just naming, implementation, and the usual "do we want this?".

The implementation seems to have proven its use in rustc at least, which many uses: https://github.com/rust-lang/rust/search?l=Rust&q=sort_by_cached_key

(I'm asking because it's exactly what I just needed the other day:
```rust
    all_positions.sort_by_cached_key(|&n|
        data::CITIES.iter()
            .map(|x| *metric_closure.get_edge(n, x.pos).unwrap())
            .sum::<usize>()
    );
```
since caching that key is a pretty obviously good idea.)

Closes rust-lang#34447

bors added a commit that referenced this pull request Feb 16, 2019

Auto merge of #58495 - kennytm:rollup, r=kennytm
Rollup of 19 pull requests

Successful merges:

 - #57929 (Rustdoc remove old style files)
 - #57981 (Fix #57730)
 - #58074 (Stabilize slice_sort_by_cached_key)
 - #58196 (Add specific feature gate error for const-unstable features)
 - #58293 (Remove code for updating copyright years in generate-deriving-span-tests)
 - #58306 (Don't default on std crate when manipulating browser history)
 - #58359 (librustc_mir: use ? in impl_snapshot_for! macro)
 - #58395 (Instant::checked_duration_since)
 - #58429 (fix Box::into_unique effecitvely transmuting to a raw ptr)
 - #58433 (Update which libcore/liballoc tests Miri ignores, and document why)
 - #58438 (Use posix_spawn_file_actions_addchdir_np when possible)
 - #58440 (Whitelist the ARM v6 target-feature)
 - #58448 (rustdoc: mask `compiler_builtins` docs)
 - #58468 (split MaybeUninit into several features, expand docs a bit)
 - #58477 (Fix the syntax error in publish_toolstate.py)
 - #58479 (compile-pass test for #53606)
 - #58489 (Fix runtime error in generate-keyword-tests)
 - #58496 (Fix documentation for std::path::PathBuf::pop)
 - #58509 (Notify myself when Clippy toolstate changes)

bors added a commit that referenced this pull request Feb 17, 2019

Auto merge of #58495 - kennytm:rollup, r=kennytm
Rollup of 19 pull requests

Successful merges:

 - #57929 (Rustdoc remove old style files)
 - #57981 (Fix #57730)
 - #58074 (Stabilize slice_sort_by_cached_key)
 - #58196 (Add specific feature gate error for const-unstable features)
 - #58293 (Remove code for updating copyright years in generate-deriving-span-tests)
 - #58306 (Don't default on std crate when manipulating browser history)
 - #58359 (librustc_mir: use ? in impl_snapshot_for! macro)
 - #58395 (Instant::checked_duration_since)
 - #58429 (fix Box::into_unique effecitvely transmuting to a raw ptr)
 - #58433 (Update which libcore/liballoc tests Miri ignores, and document why)
 - #58438 (Use posix_spawn_file_actions_addchdir_np when possible)
 - #58440 (Whitelist the ARM v6 target-feature)
 - #58448 (rustdoc: mask `compiler_builtins` docs)
 - #58468 (split MaybeUninit into several features, expand docs a bit)
 - #58479 (compile-pass test for #53606)
 - #58489 (Fix runtime error in generate-keyword-tests)
 - #58496 (Fix documentation for std::path::PathBuf::pop)
 - #58509 (Notify myself when Clippy toolstate changes)
 - #58521 (Fix tracking issue for error iterators)

@bors bors merged commit 317f153 into rust-lang:master Feb 17, 2019

1 check failed

homu Test failed
Details

@scottmcm scottmcm deleted the scottmcm:stabilize-sort_by_cached_key branch Feb 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment