Skip to content

Suggest ok_or over map_or when possible #10045

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
chubei opened this issue Dec 7, 2022 · 0 comments · Fixed by #11864
Closed

Suggest ok_or over map_or when possible #10045

chubei opened this issue Dec 7, 2022 · 0 comments · Fixed by #11864
Labels
A-lint Area: New lints

Comments

@chubei
Copy link

chubei commented Dec 7, 2022

What it does

Check for usage of _.map_or(Err(_), Ok).

Lint Name

option_map_or_err_ok

Category

pedantic

Advantage

  • Readability: this can be written more concisely as _.ok_or(_).

Drawbacks

No response

Example

opt.map_or(Err(e), Ok);

Could be written as:

opt.ok_or(e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant