Skip to content

Improve let-chain indentation #6636

@A4-Tacks

Description

@A4-Tacks

Current formatted code:

fn too_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxx()
-> Option<i32> {
    None
}

fn main() {
    if let Some(x) =
        too_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxx()
        && x != 0
    {
        println!("x")
    }
}

If you don't pay attention to the = at the end of the previous line,
you may think that this call returns a bool

Expect improved formatted code:

fn too_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxx()
-> Option<i32> {
    None
}

fn main() {
    if let Some(x)
        = too_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxx()
        && x != 0
    {
        println!("x")
    }
}

or

fn too_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxx()
-> Option<i32> {
    None
}

fn main() {
    if let Some(x) =
            too_long_function_name_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxx()
        && x != 0
    {
        println!("x")
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions