-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve into_outcome w/ try! #597
Comments
I agree we should do this, but I don't think this is the right place to fix it. Instead, since Try::from_error(From::from(v : Error)) We get: Try::from_error(From::from(v : Result<Forward, Error>)) And thus One way to fix this, barring upstream changes to the impl<F, T: From<F>, E> From<T> for BadOutcome<T, E>;
impl<E, T: From<E>, F> From<T> for BadOutcome<F, T>; We'd presumably get the behavior we want. Except trait coherence prevents this and any other approach similar to this from working due to existing blanket impls in |
The recent |
It's common to convert between different Error types using From conversions (the popular error_chain and failure crates both promote this). Rust's try! automatically calls .into() to facilitate these conversions.
into_outcome is not uncommonly used w/ try! but when done so becomes a barrier from try! making the conversion. In this situation callers are forced to call .into() themselves manually, e.g.:
https://github.com/mozilla-services/megaphone/blob/98cf97b/src/http.rs#L46
into_outcome could and really should call .into() on Errors for us. A diff for a couple of the impls:
The text was updated successfully, but these errors were encountered: