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

Lint ignored_map_err #42

Open
Veetaha opened this issue Jul 28, 2023 · 0 comments
Open

Lint ignored_map_err #42

Veetaha opened this issue Jul 28, 2023 · 0 comments
Labels
A-user-story Area: A user story or a related issue

Comments

@Veetaha
Copy link

Veetaha commented Jul 28, 2023

Lint explanation

Detect code that uses let _ = result.map_err(); pattern instead of if-let. The reasoning is that map_err is meant for changing the error type of the result, so it does more than just inspecting the error result. if-let intentionally ignores any values that don't match the pattern and is subjectively clearer, and objectively shorter.

Example code

Bad

let _ = do_something_fallible().map_err(|err| {
	// log the error
});

Good

if let Err(err) = do_something_fallible() {
	// log the error
}
@Veetaha Veetaha added the A-user-story Area: A user story or a related issue label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-user-story Area: A user story or a related issue
Projects
None yet
Development

No branches or pull requests

1 participant