Skip to content

Suggestion: Single if let instead of nested if let { if let #2521

Closed
@pickfire

Description

@pickfire

Use a single if let instead of a nested one whenever possible:

let value = Some(Err("Some error"));
if let Some(Err(ref error)) = value { // TODO
    return Err(format!("Error parsing 'value': {}", error));
}

Instead of:

let value = Some(Err("Some error"));
if let Some(ref result) = value {
    if let Err(ref error) = *result {
        return Err(format!("Error parsing 'value': {}", error));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-styleLint: Belongs in the style lint groupT-ASTType: Requires working with the AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions