rylev opened PR #5853 from result-alias
to main
:
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
As discussed on Zulip, thebindgen!
macro assumes the usage ofanyhow
. This adds a type alias towasmtime
forstd::result::Result<T, anyhow::Error>
that allows users to usewasmtime::Result
where astd::result::Result<T, anyhow::Error>
is expected.In particular, this means that users of
bindgen!
can usewasmtime::Result
when they are implementing an import function.One caveat: after making this change, I realized that the
bindgen!
macro has thetrappable_error_type
option which could be used to change the error type assume. While some changes need to be made no matter what (as many of the methods generated by the macro still assumeanyhow
and don't respect that option), we might want to consider not adding this type alias and just making it clearer that users should use thetrappable_error_type
option if they are not usinganyhow
.r? @alexcrichton
pchickey submitted PR review.
pchickey submitted PR review.
pchickey created PR review comment:
I'd add a note saying that the type is identical to
anyhow::Result
as well
abrown submitted PR review.
abrown submitted PR review.
abrown created PR review comment:
/// A convenience wrapper for `Result<T, anyhow::Error>`.
rylev updated PR #5853 from result-alias
to main
.
alexcrichton submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Could this be
pub use anyhow::{Result, Error}
perhaps? One key feature this is currently missing is theE
generic defaulting toanyhow::Error
but still allowing two generics.
alexcrichton created PR review comment:
e.g. from my comment above this shouldn't need to use
std::result::
ideally
rylev updated PR #5853 from result-alias
to main
.
rylev updated PR #5853 from result-alias
to main
.
alexcrichton submitted PR review.
alexcrichton merged PR #5853.
Last updated: Dec 23 2024 at 12:05 UTC