Skip to content

Unchecked indexing/slicing methods should point towards their safe counterparts #39911

Closed
@jonas-schievink

Description

@jonas-schievink
Contributor

The following unsafe unchecked indexing / slicing methods don't refer to the safe alternatives at all, misleading newbies into thinking that they are the preferred way of performing that operation. There should be a big disclaimer stating what their checked counterparts are and that they are preferred.

  • str::slice_unchecked / str::slice_mut_unchecked
  • [T]::get_unchecked / [T]::get_unchecked_mut

Activity

Mark-Simulacrum

Mark-Simulacrum commented on May 23, 2017

@Mark-Simulacrum
Member

cc @rust-lang/docs, this feels like an E-easy issue to me, tagging as such -- we should add the links to the unchecked method documentations pointing to safe indexing (get, probably, where applicable as well as noting indexing with the Index trait). Does that sound good?

added
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
on May 23, 2017
GuillaumeGomez

GuillaumeGomez commented on May 23, 2017

@GuillaumeGomez
Member

@Mark-Simulacrum: Yep, all good.

citizen428

citizen428 commented on May 25, 2017

@citizen428
Contributor

If no-one picks it up until then I'll try to get this done over the weekend.

GuillaumeGomez

GuillaumeGomez commented on May 25, 2017

@GuillaumeGomez
Member

@citizen428: Sure, go ahead.

added 2 commits that reference this issue on May 26, 2017

Rollup merge of rust-lang#42236 - citizen428:docs/unchecked-indexing-…

Rollup merge of rust-lang#42236 - citizen428:docs/unchecked-indexing-…

citizen428

citizen428 commented on Jun 5, 2017

@citizen428
Contributor

This has been merged, so the issue should be closed.

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 toolsE-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

        Participants

        @citizen428@jonas-schievink@GuillaumeGomez@Mark-Simulacrum

        Issue actions

          Unchecked indexing/slicing methods should point towards their safe counterparts · Issue #39911 · rust-lang/rust