Closed ranweiler closed 3 years ago
Is this something you'd be interested in supporting?
generally, yes. the only complication here is yaxpeax-arch
being #![no_std]
and std::error::Error
... being std::
. so Arch
will need another permutation of flags, similar to the use-serde
flag, to include std
and an Error
bound: https://github.com/iximeow/yaxpeax-arch/blob/master/src/lib.rs#L52-L68
i have no idea what the expectations of trying to ?
in no_std
code might be like, but i assume a lack of Error
in core
implies that no one would be missing it there. that leaves me comfortable that no one is going to trip over a missing Error
bound, so i see no reason why not (given the above required tweaking)
:wave: oh dang, this was so long ago! I'd still love to see this. Would you like a PR for it?
oh! i'd thought we talked about Error
somewhere, totally lost this issue. there's a smattering of changes to yaxpeax-arch on the way - this should be simple enough to include but a PR right now will probably just end up with weird conflicts. i'll probably include this in the next few days anyway.
okay! in std
builds of yaxpeax-arch
, DecodeError
now requires std::error::Error
. only yaxpeax-x86=1.0 conforms to this at the moment, so using yaxpeax-arch 0.2.x
is currently a good way to disable all the other decoders, if you use any others. they'll probably be updated shortly though, and everything should be std::error::Error
-compatible in a bit.
i've tried to guess at how users might expect anyhow
errors to fit (based somewhat on your example) and written some tests that the crate does actually behave properly, so i think this covers your needs! i did have an issue at first setting up the bounds (see also the ill-fated yaxpeax-arch 0.1.0) so if you can +ack then i'll close this.
Yesss, thanks @iximeow! Everything works just like I wanted (for both ad hoc and custom error types).
Motivation: I would like to be able to easily use
yaxpeax
withanyhow
(for ad hoc application errors) andthiserror
(for writing custom error types for libraries). Ifyaxpeax-arch
had astd::error::Error
bound onyaxpeax_arch::DecodeError
(and all that implies), then the following examples would work:anyhow:
Currently we get:
thiserror:
The error in this test case (omitted) is misleading, but the root cause is the same.
Is this something you'd be interested in supporting?