Skip to content
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

Enhanced doucmentation of binary search methods for slice and VecDeque for unsorted instances #106985

Merged
merged 2 commits into from
Mar 30, 2023

Conversation

jofas
Copy link
Contributor

@jofas jofas commented Jan 17, 2023

Fixes #106746. Issue #106746 raises the concern that the binary search methods for slices and deques aren't explicit enough about the fact that they are only applicable to sorted slices/deques. I changed the explanation for these methods. I took the relatively harsh description of the behaviour of binary search on unsorted collections ("unspecified and meaningless") from the description of the partition_point method:

If this slice is not partitioned, the returned result is unspecified and meaningless, as this method performs a kind of binary search.

@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 17, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@jofas jofas changed the title Fix for issue 106746 Enhanced doucmentation of binary search methods for slice and VecDeque for unsorted instances Jan 18, 2023
@ChrisDenton
Copy link
Member

This looks like a clear improvement to me. I admit I did have to think a bit about the phrase "unspecified and meaningless". But, as you say, it's consistent with partition_point and I think it expresses the "garbage in, garbage out" nature of these APIs.

So let's see if we can get this merged!

@bors r+

@bors
Copy link
Contributor

bors commented Mar 29, 2023

📌 Commit 37ed3ce has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 29, 2023
@ChrisDenton
Copy link
Member

Oops, I just notice a small issue.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 29, 2023
@ChrisDenton
Copy link
Member

ChrisDenton commented Mar 29, 2023

Lower down in the doc comments there are markdown link references like:

    /// [`contains`]: VecDeque::contains

These should also be removed as they are no longer used.

@jofas
Copy link
Contributor Author

jofas commented Mar 30, 2023

Oh my, sorry for the sloppiness. I removed the deprecated links.

@ChrisDenton
Copy link
Member

Thanks! And sorry for only noticing at the last minute

@bors r+

@bors
Copy link
Contributor

bors commented Mar 30, 2023

📌 Commit b085007 has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 30, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 30, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#106985 (Enhanced doucmentation of binary search methods for `slice` and `VecDeque` for unsorted instances)
 - rust-lang#109509 (compiletest: Don't allow tests with overlapping prefix names)
 - rust-lang#109719 (RELEASES: Add "Only support Android NDK 25 or newer" to 1.68.0)
 - rust-lang#109748 (Don't ICE on `DiscriminantKind` projection in new solver)
 - rust-lang#109749 (Canonicalize float var as float in new solver)
 - rust-lang#109761 (Drop binutils on powerpc-unknown-freebsd)
 - rust-lang#109766 (Fix title for openharmony.md)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d6f2740 into rust-lang:master Mar 30, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unclear behavior of binary search on unsorted structures
6 participants