bikeshedder / deadpool

Dead simple pool implementation for rust with async-await
Apache License 2.0
1.08k stars 137 forks source link

Remove Result<_, InteractError> from interact signature #365

Open bikeshedder opened 2 weeks ago

bikeshedder commented 2 weeks ago

The return type of interact is questionable at best:

I'm proposing to remove this Result from the call signature

-pub async fn interact<F, R>(&self, f: F) -> Result<R, InteractError>
+pub async fn interact<F, R>(&self, f: F) -> R

What happens in the error cases?

It just panics. :boom:

Why is this a good thing?

I think most users of the library will just log an error and ignore the InteractError anyways. The default behavior should be to escalate the error rather than trying to handle it "gracefully".

For those people that really know what they're doing and need to handle panics an additional interact_safe could be added which does behave exactly like before.

I'm interested to hear from users of this library if they ever had a need for handling a panic (or abortion) after an interact call.