Skip to content

Add result_and_then_ok lint #4412

Closed
Closed
@flip1995

Description

@flip1995

In #4386 the option_and_then_some lint was added. This can also be implemented for result_and_then_ok:

fn foo() -> Result<(), ()> {
    let x = Ok(10);
    x.and_then(Ok); // This is a noop -> `x`
    x.and_then(|x| Some(..)); // This should be a `map` -> `x.map(|x| ..)`
}

Originally posted by @flip1995 in #4386

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-complexityLint: Belongs in the complexity lint groupL-suggestionLint: Improving, adding or fixing lint suggestionsgood 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