-
Notifications
You must be signed in to change notification settings - Fork 151
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
Replace failure
with thiserror
#39
Comments
I'd be in favor of it. Any thoughts on this @dignifiedquire @str4d ? |
Yes, fully in favor, I have been switching most of my crates over alrady. |
Cool, well now that we're in agreement, let me offer the one con of doing it 😅 This crate presently doesn't support @dtolnay I don't suppose there's a That said, since this crate doesn't support |
Looking at the PR it seems you mainly need a Display derive, not an Error derive. If you can find a good one of those, no_std support would look like: #[derive(Display, Debug)]
pub enum Error {
...
}
#[cfg(feature = "std")]
impl std::error::Error for Error {} |
@dtolnay good point! I write the above in a lot of libraries (that is to say, a manual Perhaps @yaahc's displaydoc is a good candidate? |
I am not a fan of that approach with doc comments =/ but it's a choice of personal taste. The implementation is good. ;) Honestly in your case I don't think a proc macro is called for unless one of your dependencies is already pulling it in; you can easily handwrite the one Display impl. |
Error types created by
failure
do not implementstd::error::Error
which prevents usage of the?
operator. Thethiserror
crate provides similar functionality but is fully compatible with the standard library and RFC2504.I'm happy to submit a PR with the changes but I want collect feedback first.
https://github.com/dtolnay/thiserror
https://github.com/dtolnay/anyhow
The text was updated successfully, but these errors were encountered: