Open danakj opened 1 year ago
I'm adding Error
and its type-erased Box<DynError>
and that means a function returning Result<T, Box<DynError>>
can return any Error
if it spells it sus::err(sus::into(SomeErrorType()))
so the TRY macro should also do the into
step.
Chromium is gaining
RETURN_IF_ERROR(e)
which is built aroundbase::expected
(likestd::expected
).STX has
TRY_OK
andTRY_SOME
which are similar and hard coded to itsResult
andOption
types.Subspace has a
sus::ops::Try
concept which is used to early terminate operations like try_fold. The concept is satisfied bysus::result::Result
andsus::Option
. It can be extended to makestd::optional
andstd::expected
satisfysus::ops::Try
as well, in the same way thatstd::vector
now satisfiessus::iter::FromIterator
.Providing a
TRY()
macro that will early out when theTry
object reports failure would allow this mechanism to be applied across many different types.If needed we can add additional hooks into the requirements of the
Try
concept to provide good error messages.