-
Notifications
You must be signed in to change notification settings - Fork 65
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
orElse
for Error Type Transformation
#95
Comments
This seems like a good idea and would be a backwards-compatible change. I'm wondering if there was a reason I didn't do it like this originally - maybe Rust's reference impl wasn't always like this? Either way seems like a good change - are there any other callsites like this that would benefit from the increased signature mapping capability? |
I wonder too, but the Rust implementation does not seem to have changed since at least version 1.0. <V, E, U> Result<V, E>.map(transform: (V) -> U): Result<U, E> For Rust: impl Result<V, E> {
// many
// other
// methods
// ...
pub fn map<U>(self, op: fn(V) -> U) -> Result<U, E>
} Here, I have only been able to find out about the Rust and Haskell on wiki, but besides <V, E> Result<V, E>.and(result: Result<V, E>): Result<V, E> I think the type of the success value in the argument can be made arbitrary. <V, E, U> Result<V, E>.and(result: Result<U, E>): Result<U, E> Similarly, <V, E> Result<V, E>.or(result: Result<V, E>): Result<V, E> I believe the error type can also be made arbitrary. <V, E, F> Result<V, E>.or(result: Result<V, F>): Result<V, F> |
Hello.
Currently,
Result.orElse
has the following signature:However, it does not allow for changing the type of the error. Rust's or_else can change it, so how about modify it to align with that capability?
thanks!
The text was updated successfully, but these errors were encountered: