You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then in the code I have statements like this return XyzSnafu { .. }.fail().into(). Basically I want to combine that fail() + into() (and similarly for build) into a single call, e.g:
trait MyResExt {
fn fail_into() -> Error;
}
But here's the problem, there's no generic type bound to implement it for and use fail/build in implementation. So is there any reason why it doesn't exist?
The text was updated successfully, but these errors were encountered:
The big one would be that using a trait for build or fail would require the user to import that trait first. That's not insurmountable, but it's an annoying papercut. If "inherent traits" were a thing, then this would be an easy win.
Without that, the next best thing would be some kind of adjacent implementation, e.g.
Note that this is also annoying as there are different names (IIRC this is required because you can't disambiguate a trait and inherent method of the same name).
In cases where I've wanted to be generic over selectors, I usually end up using the IntoError trait. Note that you may need to use NoneError for your case.
I want to wrap a snafu-managed error with mine that captures some implicit context. Basically I do smth like this:
Then in the code I have statements like this
return XyzSnafu { .. }.fail().into()
. Basically I want to combine thatfail() + into()
(and similarly for build) into a single call, e.g:But here's the problem, there's no generic type bound to implement it for and use fail/build in implementation. So is there any reason why it doesn't exist?
The text was updated successfully, but these errors were encountered: