Skip to content

Add suggestion to if_let_some_result lint #4991

Closed
@JohnTitor

Description

@JohnTitor

It'd be nice for if_let_some_result to have suggestions. I think implementation should be easy.

https://rust-lang.github.io/rust-clippy/master/index.html#if_let_some_result

Example:

fn str_to_int(x: &str) -> i32 {
    if let Some(y) = x.parse().ok() {
        y
    } else {
        0
    }
}

suggests like this:

    if let Some(y) = x.parse().ok() {
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `if let Ok(y) = x.parse()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions