Skip to content
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

Create new lint option_map_or_err_ok #11864

Merged
merged 3 commits into from Nov 25, 2023

Conversation

GuillaumeGomez
Copy link
Member

Fixes #10045.

For the following code:

let opt = Some(1);
opt.map_or(Err("error"), Ok);

It suggests to instead write:

let opt = Some(1);
opt.ok_or("error");

r? @flip1995

changelog: Create new lint option_map_or_err_ok

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 24, 2023
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/mod.rs Outdated Show resolved Hide resolved
clippy_lints/src/methods/option_map_or_err_ok.rs Outdated Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

Applied suggestions and simplified code. Like I said, I'll send a follow-up for my previous lint as well.

bors added a commit that referenced this pull request Nov 25, 2023
…e_none, r=flip1995

Simplify code for `result_map_or_else_none`

As mentioned in #11864.

r? `@flip1995`

changelog: Simplify code for `result_map_or_else_none`
@flip1995
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Nov 25, 2023

📌 Commit ef38969 has been approved by flip1995

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Nov 25, 2023

⌛ Testing commit ef38969 with merge 3664d63...

@bors
Copy link
Collaborator

bors commented Nov 25, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 3664d63 to master...

@bors bors merged commit 3664d63 into rust-lang:master Nov 25, 2023
8 checks passed
@GuillaumeGomez GuillaumeGomez deleted the option_map_or_err_ok branch November 25, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggest ok_or over map_or when possible
4 participants