Skip to content

Suggest using let-chains #14678

Closed
Closed
@nickdrozd

Description

@nickdrozd

What it does

2024 edition introduces let-chains (rust-lang/rust#53667). It would be cool if Clippy could identify places where this feature could be used. Maybe autofix too?

Advantage

  • Less nesting
  • Less logical complexity

Drawbacks

No response

Example

if let Some(x) = f() {
    if g(x) {
        dbg!(x)
    }
}

Could be written as:

if let Some(x) = f() && g(x) {
    dbg!(x)
}

Metadata

Metadata

Assignees

No one assigned

    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