Skip to content

New lint: slice.iter().next() can be replaced with slice.get() #5572

Closed
@lights0123

Description

@lights0123

As I saw in this code review, someone wrote:

while Some(&instructions[i]) == instructions[i + acc..].iter().next() {
    acc += 1;
}

That should be replaced with:

while Some(&instructions[i]) == instructions.get(i + acc) {
    acc += 1;
}

In general, slice[i..].iter().next() can be replaced with slice.get(i), or 0 if there is no slicing done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions