Skip to content

Bad example to show indices begin at 0 #363

Closed

Description

@CAESIUS-TIM

let i = xs.len() + 1;

The given example doesn't effectively show that in Rust, indices start from 0; it might even give the impression that indices begin at 1.

A common mistake is forgetting to subtract 1, as seen here:
Right: let i = xs.len() - 1;
Wrong: let i = xs.len();

Activity

  1. added a commit that references this issue on Nov 16, 2023
  2. added a commit that references this issue on Dec 11, 2023
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions