tap-rs icon indicating copy to clipboard operation
tap-rs copied to clipboard

TapOps function that would return Err if colsure returned Err?

Open jpastuszek opened this issue 5 years ago • 0 comments

Not sure if this makes sense for this crate but I happen to need this.

Current code:

let mut foo: Foo = Foo::new();
foo.do_stuff_that_can_fail()?;
let foo = foo;

Would be nice if I could just write:

let foo: Foo = Foo::new().tap_lift_err(|foo| foo.do_stuff_that_can_fail())?;

So tap_lift_err would call closure and return Ok(self) if closure result was Ok (ignoring the value) or Err from closure if it returned Err so it can be handled.

tap_lift_err is probably not the best name... What are your thoughts?

jpastuszek avatar Feb 10 '20 10:02 jpastuszek