Skip to content

Lint unnecessary .into_iter() in function arguments #10743

@yongqli

Description

@yongqli

What it does

If someone didn't know that various functions can take an impl IntoIterator instead of an impl Iterator for their arguments, they might have wrote useless explicit .into_iter()s.

See also #1094

Lint Name

explicit_into_iter_fn_arg

Category

pedantic

Advantage

No response

Drawbacks

No response

Example

fn main() {
    let mut v = vec![];
    v.extend(vec![0].into_iter());
}

Could be written as:

fn main() {
    let mut v = vec![];
    v.extend(vec![0]);
}

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions