Skip to content

Misleading description of range in split_off() and split_off_mut() #141107

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

Closed
ProHaller opened this issue May 17, 2025 · 1 comment · Fixed by #141110
Closed

Misleading description of range in split_off() and split_off_mut() #141107

ProHaller opened this issue May 17, 2025 · 1 comment · Fixed by #141110
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

@ProHaller
Copy link

ProHaller commented May 17, 2025

Location

In the second example of each of these:

Summary

The second example of these two APIs are described as follows:

Splitting off the last two elements of a slice:

let mut slice: &[_] = &['a', 'b', 'c', 'd'];
let mut tail = slice.split_off(2..).unwrap();

assert_eq!(slice, &['a', 'b']);
assert_eq!(tail, &['c', 'd']);

I believe this is intended as a simple description of what the example is doing, which isn't wrong.
-> However, it is only correct if the slice is 4 elements total.

Suggested correction:
"Splitting off a slice from the third element to the last:"

@ProHaller ProHaller added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label May 17, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 17, 2025
@xizheyin
Copy link
Contributor

@rustbot claim

@jieyouxu jieyouxu 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 May 17, 2025
fmease added a commit to fmease/rust that referenced this issue May 18, 2025
…bilee

[std] fix the presentation of `split_off_mut` and `split_off` documentation

Fixes rust-lang#141107

r? libs
@bors bors closed this as completed in 93bc64d May 19, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 19, 2025
Rollup merge of rust-lang#141110 - xizheyin:issue-141107, r=workingjubilee

[std] fix the presentation of `split_off_mut` and `split_off` documentation

Fixes rust-lang#141107

r? libs
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue May 21, 2025
…bilee

[std] fix the presentation of `split_off_mut` and `split_off` documentation

Fixes rust-lang#141107

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