Closed
Description
What it does
Suggest that map_err
isn't a good way to inspect the error, and that inspect_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
let data = std::fs::read("some_file").map_err(|e| {
println!("failed to read from file");
e
})?;
Could be written as:
let data = std::fs::read("some_file").inspect_err(|e| {
println!("failed to read from file");
})?;