Skip to content

new lint: find unneccessary Some(x).and_then(|y| Some(y ..)) #6472

Closed
@matthiaskrgr

Description

@matthiaskrgr

What it does

Catch Some(..).and_then(|..| Some(..)) patterns.

What does this lint do?
Suggest to simplify the statement to Some(do something with x and y)
For example Some(3).and_then(|x| Some(x+4)); could be simplified to Some(3+4)

Categories (optional)

Complexity, maybe pedantic.

What is the advantage of the recommended code over the original code
It's way easier to understand

Drawbacks

None.

Example

Some(3).and_then(|x| Some(x+4));

Could be written as:

Some(3+4)

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsL-complexityLint: Belongs in the complexity lint groupgood 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