Skip to content

std: fix doctest and explain for as_slices and as_mut_slices in VecDeque #141230

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

Merged
merged 1 commit into from
May 22, 2025

Conversation

xizheyin
Copy link
Contributor

Fixes #141217

r? libs

@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 May 18, 2025
@VorfeedCanal
Copy link

https://doc.rust-lang.org/std/collections/struct.VecDeque.html#method.as_mut_slices

as_mut_slices have the same issue, should it be fixed, too? It's more complicates there because example directly changes slices… which can lead to different outcome or even crash, if internal algorithm of VecDec would change.

@xizheyin
Copy link
Contributor Author

In the changes, I also fixed the doc of as_mut_slice,but I typo in the pr title. lol

@xizheyin xizheyin changed the title std: fix doctest and explain for as_slice and as_slice_mut in VecDeque std: fix doctest and explain for as_slices and as_mut_slices in VecDeque May 19, 2025
@xizheyin
Copy link
Contributor Author

Lone time no see. Thanks for your suggestion, I modified the code as you suggested. I have a little concern that closure in the example of as_mut_slices will be difficult to understand for new comers (I'm not sure if the closure is a required knowledge for new comers).

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, the changes lgtm.

I have a little concern that closure in the example of as_mut_slices will be difficult to understand for new comers (I'm not sure if the closure is a required knowledge for new comers).

I think they are usually introduced pretty early, but it doesn't have to be a closure. If you prefer, it can be a fn updat_nth(deque: &mut VecDeque<u32>, index: usize, val: u32).

Please squash then r=me with or without changing to a function.

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
@xizheyin
Copy link
Contributor Author

There doesn't seem to be anything wrong with using the base closure. :)

@bors r=tgross35

@bors
Copy link
Collaborator

bors commented May 21, 2025

@xizheyin: 🔑 Insufficient privileges: Not in reviewers

@xizheyin
Copy link
Contributor Author

Oh, I does not have permission to merge it. @tgross35

@tgross35
Copy link
Contributor

Thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented May 21, 2025

📌 Commit 46a5c91 has been approved by tgross35

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 May 21, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#140526 (docs: Specify that common sort functions sort in an ascending direction)
 - rust-lang#141230 (std: fix doctest and explain for `as_slices` and `as_mut_slices` in `VecDeque`)
 - rust-lang#141341 (limit impls of `VaArgSafe` to just types that are actually safe)
 - rust-lang#141347 (incorrectly prefer builtin `dyn` impls :3)
 - rust-lang#141351 (Move -Zcrate-attr injection to just after crate root parsing)
 - rust-lang#141356 (lower bodies' params to thir before the body's value)
 - rust-lang#141357 (`unpretty=thir-tree`: don't require the final expr to be the body's value)
 - rust-lang#141363 (Document why we allow escaping bound vars in LTA norm)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit b5edec2 into rust-lang:master May 22, 2025
6 checks passed
@rustbot rustbot added this to the 1.89.0 milestone May 22, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 22, 2025
Rollup merge of rust-lang#141230 - xizheyin:issue-141217, r=tgross35

std: fix doctest and explain for `as_slices` and `as_mut_slices` in `VecDeque`

Fixes rust-lang#141217

r? libs
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.

VecDeque documentation for as_slices misleads newbies.
5 participants