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

Clarify documentation of slice sorting methods #85985

Merged
merged 1 commit into from
Jun 8, 2021
Merged

Clarify documentation of slice sorting methods #85985

merged 1 commit into from
Jun 8, 2021

Conversation

Lionelf329
Copy link
Contributor

After reading about this, I realized that although the documentation of these methods is not ambiguous in its current state, it is very easy to read it and erroneously assume that their exact behaviour can be relied upon to be deterministic. Although the docs make no guarantees about which index is returned when there are multiple matches, being more explicit about when and how their determinism can be relied upon should help prevent people from making this mistake in the future.

r? @steveklabnik

@rust-highfive
Copy link
Collaborator

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

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 4, 2021
@steveklabnik
Copy link
Member

this is a @rust-lang/libs decision, so I would prefer that someone from that team review.

/// [`Result::Err`] is returned, containing the index where a matching
/// element could be inserted while maintaining sorted order.
/// one of the matches could be returned. The index is chosen
/// deterministically, but is subject to change between releases. If the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// deterministically, but is subject to change between releases. If the
/// deterministically, but is subject to change in future versions of Rust. If the

(Likewise for the other two comments.)

@joshtriplett
Copy link
Member

Seems reasonable to me, modulo the minor comment nit I posted (which applies to all three comments).

@joshtriplett
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jun 7, 2021

📌 Commit fddf012 has been approved by joshtriplett

@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 Jun 7, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jun 8, 2021
Clarify documentation of slice sorting methods

After reading about [this](https://polkadot.network/a-polkadot-postmortem-24-05-2021/), I realized that although the documentation of these methods is not ambiguous in its current state, it is very easy to read it and erroneously assume that their exact behaviour can be relied upon to be deterministic. Although the docs make no guarantees about which index is returned when there are multiple matches, being more explicit about when and how their determinism can be relied upon should help prevent people from making this mistake in the future.

r? `@steveklabnik`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 8, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#85906 (Use `Iterator::find` instead of open-coding it)
 - rust-lang#85951 (Update the documentation of `-C force-unwind-tables` for rust-lang#83482)
 - rust-lang#85985 (Clarify documentation of slice sorting methods)
 - rust-lang#85989 (Remove rustfmt tests from top-level .gitattributes)
 - rust-lang#86074 (Default panic message should print Box<dyn Any>)
 - rust-lang#86078 (Type page font weight)
 - rust-lang#86090 (:arrow_up: rust-analyzer)
 - rust-lang#86095 (Search description codeblock)
 - rust-lang#86096 (Comment out unused error codes and add description for E0316)
 - rust-lang#86101 (Correct type signature in doc for Bound::as_mut)
 - rust-lang#86103 (Remove lifetime hack)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 2a23af6 into rust-lang:master Jun 8, 2021
@rustbot rustbot added this to the 1.54.0 milestone Jun 8, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants