-
Notifications
You must be signed in to change notification settings - Fork 211
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
recommend core::error::Error
for ErrorType::Error
#633
Comments
core::error::Error
for Errorscore::error::Error
for ErrorType::Error
As you mention, this is a breaking change so it'd have to be released as Even if upgrading 1.0->2.0 is easy, the real burden is the ecosystem split it causes. A HAL implementing v2.x won't work with a driver requiring v1.x. There's many lightly-maintained or unmaintained HALs/drivers, we've seen this with 0.2->1.0. Almost 1 year after the release of v1.0 there's quite a few HALs and a lot of drivers that still haven't upgraded to 1.0. This was discussed in a WG meeting when merging #630, the conclusion was this is something we do want if we do 2.0, but it alone it's not worth the burden of doing a 2.0 release. |
Maybe adding the adapters and a trait for those in a separate crate is a non-terrible work around. |
FTR and AFAICT this wasn't discussed when merging but two weeks ago. Also note that this situation is different from the 0.2-1.0 breakage. There seem to be two other options here:
(To be clear: I also think that |
this seems pretty reasonable to me. no weird trait tricks, it's a nice way to push for gradual adoption, and per @Dirbaio's point the strict requirement can go in a pile for a possible (one day, maybe) 2.0. |
What's the opinion on the following steps?
|
core::error::Error
for ErrorType::Error
core::error::Error
for ErrorType::Error
As of #630 the
ErrorKind
structs implementError
.As explained in #630 (comment)
its difficult to make good use of that unless the e-h traits add a
core::error::Error
bound to theirErrorType::Error
type:A device driver that uses a e-h trait wants to return the hal's Error from its impl of
core::error::Error::source() -> Option<&dyn core::error::Error>
. Returning theErrorKind
is hard/annoying/inefficient due to the need to store it. The "good" way to do that is appears to either requirecore::error::Error
for the hal's Errors or for each device driver to implement newtype wrappers for any hal Error (which are then limited as they can only rely onError::kind()
andDebug
).Adding that bound is obviously breaking. But the burden is manageable: (1) the MSRV bump is already there (2) a trivial impl of
core::error::Error
will always be sufficient and in most cases even complete (3)thiserror
and other crates make the job easy.The text was updated successfully, but these errors were encountered: