这是indexloc提供的服务,不要输入任何密码
Skip to content

New lint: suggest the use of Result::unwrap_or_else over Result::map_or_else #7328

@jhscheer

Description

@jhscheer

What it does

Suggest the use of Result::unwrap_or_else over Result::map_or_else if map_or_else is just used to unpack a successful result while handling an error.

Categories (optional)

What is the advantage of the recommended code over the original code

Code will be shorter (and cleaner).

Drawbacks

None.

Example

.map_or_else(
    |e| handle_the_error(e),
    |n| n,
)

Could be written as:

.unwrap_or_else(|e| handle_the_error(e))

Metadata

Metadata

Labels

C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood 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