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

[_]::windows needs better examples to avoid confusion #118571

Closed
JohnTheCoolingFan opened this issue Dec 3, 2023 · 1 comment · Fixed by #118586
Closed

[_]::windows needs better examples to avoid confusion #118571

JohnTheCoolingFan opened this issue Dec 3, 2023 · 1 comment · Fixed by #118586
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@JohnTheCoolingFan
Copy link
Contributor

JohnTheCoolingFan commented Dec 3, 2023

Location

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

Summary

The documentation only shows an example with windows of size 2 and an example with windows of size 3, but the resulting slice is mutated and it woudl be hard to understand what exactly windows returns. For example, my previous assumption was that there was an overlap of only one element and not size - 1. An example with window size larger than 2 would help avoid this confusion.

@JohnTheCoolingFan JohnTheCoolingFan added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Dec 3, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 3, 2023
@JohnTheCoolingFan JohnTheCoolingFan changed the title [_]::windows needs better examples ro vaoid confusion [_]::windows needs better examples to avoid confusion Dec 3, 2023
@saethlin saethlin added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Dec 4, 2023
@gurry
Copy link
Contributor

gurry commented Dec 4, 2023

@rustbot claim

rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 4, 2023
Rollup merge of rust-lang#118586 - gurry:118571-improve-slice-doc-example, r=thomcc

Improve example in `slice::windows()` doc

Fixes rust-lang#118571

Now using a window of 3 instead 2 because it removes any confusion about exactly how consecutive windows overlap
@bors bors closed this as completed in f1397e6 Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants