rust-lang / rust-lang/rust-clippy

lint None.into_iter()?

Open
#8,529 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

What it does

If we want to have something like an iterator that starts with certain item and then continues with another range of items, we can do something like chaining an iterator to an option:

Some(0).into_iter().chain(vec![1, 2, 3].into_iter())

Although it does not make a lot of sense, this works with None as well but the first item will not be saved in the iterator.

 None::<i32>.into_iter().chain(vec![1, 2, 3].into_iter())

I wonder if it makes sense to lint something like None.(into_)iter() and suggest std::iter::empty or removing the code entirely.

Lint Name

none_to_iter? none_into_iter?

Category

style, complexity

Advantage

No response

Drawbacks

No response

Example
 None::<i32>.into_iter().chain(vec![1, 2, 3].into_iter())

Could be written as:

vec![1,2,3].into_iter()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source files, tests, or entry points. Start by reviewing the proposed Rust examples and determine the exact scope and expected behavior for a None iterator lint; completion requires a settled lint proposal with testable expectations.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.