Inspect methods for Result


#1

I often want to log and propagate errors so I can be a bit more specific about where an error happened.

Currently there’s no nice way to do this. I can use match. I can use map_err. I can use a few other things. None of those are nice.

I’d like an inspect(|t| ()) and inspect_err(|e| ()), as the name implies they take a closure that takes in a &ref and returns nothing (()), and return the original Result.


#2

You can add such method to Result by creating and implementing your own trait.

Also see error_chain and failure crates. Both add more context and helper methods to errors.