Description
Per #1288 (comment):
Error types like
SizeError
do not implementstd::error::Error
, so the functions likeread_from_bytes()
that now return aResult
can't be used withanyhow::Context
, while the previous version that returnedOption
could. SinceDebug
andDisplay
are already implemented, I think this should just be a matter of addingimpl std::error::Error for SizeError {}
, but I didn't actually try this out. It may still not be possible to call.context()
due to other constraints (Send + Sync
). This is easy enough to work around (assuming the caller doesn't really care about the underlying error), and we didn't use this pattern in many places, so it's not really a big deal for us.
Implementing std::error::Error
is implemented in #1298.
Supporting Send + Sync
may be harder, since the contained Src
type may not be Send
or Sync
. We may need to provide a way to discard the Src
type, and we will need to consider how discoverable this mechanism is for people who are encountering a trait-not-satisfied error. I could see a few options:
- Provide an
Error<Src> -> Error<()>
conversion - Provide a new type alias
type Foo = Error<()>
so that type signatures are cleaner - Provide an entirely new type which contains similar information to the original error, but without the source
- Provide an entirely new type which contains the name of the source type, but doesn't contain an instance of the source type (just like we do for
Dst
right now)