-
Couldn't load subscription status.
- Fork 141
program-error!: Improve ToStr ergonomics #189
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
Conversation
|
#191 will address the CI failure |
| pub trait ToStr { | ||
| fn to_str<E>(&self) -> &'static str | ||
| where | ||
| E: 'static + ToStr + TryFrom<u32>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Is requiring fewer bounds a breaking change? |
Ah, it is on the |
#### Problem The `ToStr` trait is a bit difficult to use, forcing a lot of redundant uses of types, when programs will just want to call `err.to_str::<MyError>()`. #### Summary of changes Simplify the trait to not require anything, then add a generic `to_str` function directly on `ProgramError` that allows us to get the error message for a particular error type. Also, clarify the deprecation warning on `DecodeError`. BREAKING CHANGE: the `ToStr` trait requires fewer bounds
#### Problem The `ToStr` trait is a bit difficult to use, forcing a lot of redundant uses of types, when programs will just want to call `err.to_str::<MyError>()`. #### Summary of changes Simplify the trait to not require anything, then add a generic `to_str` function directly on `ProgramError` that allows us to get the error message for a particular error type. Also, clarify the deprecation warning on `DecodeError`. BREAKING CHANGE: the `ToStr` trait requires fewer bounds
Problem
The
ToStrtrait is a bit difficult to use, forcing a lot of redundant uses of types, when programs will just want to callerr.to_str::<MyError>().Summary of changes
Simplify the trait to not require anything, then add a generic
to_strfunction directly onProgramErrorthat allows us to get the error message for a particular error type.Also, clarify the deprecation warning on
DecodeError.BREAKING CHANGE: the
ToStrtrait requires fewer bounds