-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Suggest inspect_err
instead of map_err
with a closure that returns the original error
#12250
Labels
A-lint
Area: New lints
Comments
eric-seppanen
changed the title
Suggest
Suggest Feb 9, 2024
inspect_err
instead of map_err
with a closure that returns inspect_err
instead of map_err
with a closure that returns the original error
Looks like I was too slow :) #12287 |
bors
added a commit
that referenced
this issue
Jun 15, 2024
Add lint `manual_inspect` fixes #12250 A great example of a lint that sounds super simple, but has a pile of edge cases. changelog: Add lint `manual_inspect`
bors
added a commit
that referenced
this issue
Jun 16, 2024
Add lint `manual_inspect` fixes #12250 A great example of a lint that sounds super simple, but has a pile of edge cases. ---- changelog: Add lint `manual_inspect`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What it does
Suggest that
map_err
isn't a good way to inspect the error, and thatinspect_err
should be used instead.Advantage
The resulting code is a little bit simpler, and doesn't imply things that aren't true ("map" implies we are changing the error).
Drawbacks
inspect_err
was stabilized in 1.76.0. Other than that this seems pretty safe?Example
Could be written as:
The text was updated successfully, but these errors were encountered: