Skip to content

DOC: slicing with begin = end? #75412

Closed
@mgeier

Description

@mgeier
Contributor

https://doc.rust-lang.org/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E mentions "Panics [...] if begin > end, or if end > len", which I think is correct.

However, https://doc.rust-lang.org/std/slice/trait.SliceIndex.html#impl-SliceIndex%3Cstr%3E-1 mentions "Panics [...] if begin >= len", which I think is wrong, isn't it?

Shouldn't this be "Panics [...] if begin > len"?

The current stable compiler doesn't seem to create a panicking program when I use "begin = len".

The documentation for slice slicing doesn't mention anything at all: https://doc.rust-lang.org/std/slice/trait.SliceIndex.html#impl-SliceIndex%3C%5BT%5D%3E-2.

It would be great to have the (correct) description there as well.

I think this has already been fixed in #32099 and #32183 (more than 4 years ago), but it seems to have gotten lost again since then?

Or am I missing something?

Activity

JohnTitor

JohnTitor commented on Aug 13, 2020

@JohnTitor
Member

You're right, I guess it's a copy/paste error from RangeToInclusive in #57604? We're happy to see a PR to fix it :)

added
C-bugCategory: This is a bug.
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
on Aug 13, 2020
added 5 commits that reference this issue on Aug 18, 2020

Rollup merge of rust-lang#75499 - jack-champagne:jack-champagne/issue…

bc4b517

Rollup merge of rust-lang#75499 - jack-champagne:jack-champagne/issue…

61e2369

Rollup merge of rust-lang#75499 - jack-champagne:jack-champagne/issue…

5fe695b

Rollup merge of rust-lang#75499 - jack-champagne:jack-champagne/issue…

9112168

Rollup merge of rust-lang#75499 - jack-champagne:jack-champagne/issue…

9b5522a
added a commit that references this issue on Aug 19, 2020

Rollup merge of rust-lang#75499 - jack-champagne:jack-champagne/issue…

ac264b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @mgeier@JohnTitor

      Issue actions

        DOC: slicing with begin = end? · Issue #75412 · rust-lang/rust