Skip to content

.slice() method documentation slightly misleading / inaccurate #14577

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
Meyermagic opened this issue Jun 1, 2014 · 0 comments · Fixed by #14668
Closed

.slice() method documentation slightly misleading / inaccurate #14577

Meyermagic opened this issue Jun 1, 2014 · 0 comments · Fixed by #14668

Comments

@Meyermagic
Copy link
Contributor

In:

The documentation states

Fails when start or end point outside the bounds of self

Since slice isn't inclusive, this isn't exactly true. With end == len, end definitely points outside the bounds of self (in the sense that you couldn't do v.get(end), which seems like the obvious interpretation), yet .slice will not fail.

A straightforward reading of the documentation for slice seems to suggest it is inclusive. Maybe write

Returns a slice of self from start up to, but not including, end.

or

Returns a slice of self spanning the interval [start, end).
Or something else (since both of these are kinda awkward and don't fix the next sentence).

I feel like slice's documentation should make the semantics of the method as clear and unambiguous as possible.

@huonw huonw added the A-docs label Jun 1, 2014
bors added a commit that referenced this issue Jun 6, 2014
mcpherrinm pushed a commit to mcpherrinm/rust that referenced this issue Jun 10, 2014
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants