Skip to content

assist: convert if-let/match to Option::map #20993

@pickx

Description

@pickx

there should be an assist to convert

match my_optional {
    Some(val) => { do_something(val) }
    None => None,
};

and

if let Some(val) = my_optional {
    do_something(val)
} else {
    None
};

to

my_optional.map(|val| do_something(val));

this manual re-implementation is very common. I'm not saying either is better, just that the ability to do this would be nice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions