Skip to content

Bad example to show indices begin at 0 #363

@CAESIUS-TIM

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();

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