Backporting `inspect_err` to 1.70

I am trying to support my crate to rust version 1.70 (a popular RTOS has just added support of rust but version 1.70.0 only).

I have been using inspect_err and other goodies available in 1.76 quite liberally. I was wondering if there is a easy pollyfill/crate that allows me to keep using inspect_err with 1.70?

You can use tap crate. :slight_smile:

For example:

use tap::TapFallible;

fn frobnicate() -> Result<(), &'static str> { todo!() }

fn main() {
    let _ = frobnicate().tap_err(|e| println!("failed to frobnicate: {e}"));
}
3 Likes

If you just want this one method, you can write a trait with such extension yourself.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.