Skip to content

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

Closed
@ProHaller

Description

@ProHaller

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:"

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions