Suggest inspect_err
instead of map_err
with a closure that returns the original error
#12250
Labels
A-lint
Area: New lints
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: