Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TapOps function that would return Err if colsure returned Err? #11

Open
jpastuszek opened this issue Feb 10, 2020 · 0 comments
Open

TapOps function that would return Err if colsure returned Err? #11

jpastuszek opened this issue Feb 10, 2020 · 0 comments

Comments

@jpastuszek
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant