-
Notifications
You must be signed in to change notification settings - Fork 102
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
Feature request: impl From<Error> for io::Error
#145
Comments
Doesn't the existing implementation catch it? Or do you want something more fine-grained? |
I don't think the existing implementation catches it, but I'm still learning and can believe I'm wrong! I created this repository to demonstrate my feature request: Essentially the repository code is as follows:
If I try to put the
I acknowledge that I could use |
Oh, I'm sorry. I misread your first post. I was thinking of it the other way around.... With the existing code you can create an But your suggestion sounds reasonable. (Technically MQTT is an I/O library and its errors can be considered I/O errors, right?) I hadn't even thought of it. And the implementation you suggest looks like the proper way to do it. I'll test it out. But have you tried the anyhow crate? It's a good way to deal with heterogenous errors in a Rust application, like the one you show. Even if I get the suggested fix in,
On my machine, I get:
|
Oh, and of course you could just catch a generic error if you didn't want to add the
|
Added to the |
Yaaay! Thank you!! 😃💚 |
Firstly: Thank you for this crate. :)
It would be helpful if
From<Error> for io::Error
was implemented, so that applications using this crate can use the?
operator on both crateResult
s andstd::io::Result
s.I think the implementation would be performed in
errors.rs
and would look as follows (perhaps with even morematch
cases filled in):I tested this locally with my own code, and it does indeed allow me to use the
?
operator onResult
s from this crate.The text was updated successfully, but these errors were encountered: