Skip to content

DOC: slicing with begin = end? #75412

Closed
@mgeier

Description

@mgeier

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?

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

    No branches or pull requests

    Issue actions