-
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
Fix some confusing wording and improve slice-search-related docs #90312
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments for explanations and for a question I have.
☔ The latest upstream changes (presumably #94024) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
@rustbot ready |
@bors r+ rollup |
📌 Commit c186460 has been approved by |
Fix some confusing wording and improve slice-search-related docs This adds more links between `contains` and `binary_search` because I do think they have some relevant connections. If your (big) slice happens to be sorted and you know it, surely you should be using `[3; 100].binary_search(&5).is_ok()` over `[3; 100].contains(&5)`? This also fixes the confusing "searches this sorted X" wording which just sounds really weird because it doesn't know whether it's actually sorted. It should be but it may not be. The new wording should make it clearer that you will probably want to sort it and in the same sentence it also mentions the related function `contains`. Similarly, this mentions `binary_search` on `contains`' docs. This also fixes some other minor stuff and inconsistencies.
Rollup of 6 pull requests Successful merges: - rust-lang#90312 (Fix some confusing wording and improve slice-search-related docs) - rust-lang#96149 (Remove unused macro rules) - rust-lang#96279 (rustdoc: Remove .woff font files) - rust-lang#96355 (Better handle too many `#` recovery in raw str) - rust-lang#96379 (delay bug when adjusting `NeverToAny` twice during diagnostic code) - rust-lang#96384 (do not consider two extern types to be similar) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This adds more links between
contains
andbinary_search
because I do think they have some relevant connections. If your (big) slice happens to be sorted and you know it, surely you should be using[3; 100].binary_search(&5).is_ok()
over[3; 100].contains(&5)
?This also fixes the confusing "searches this sorted X" wording which just sounds really weird because it doesn't know whether it's actually sorted. It should be but it may not be. The new wording should make it clearer that you will probably want to sort it and in the same sentence it also mentions the related function
contains
.Similarly, this mentions
binary_search
oncontains
' docs.This also fixes some other minor stuff and inconsistencies.