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
Love the python module! It makes my small codebase extremely simple and makes error handling much more sane!
What?
Though, I'm unable to get around the fact that Result.map_err has the effective func sig of:
map_err :: Result<T, E> -> (E -> F) -> Result<T, E | F>
The original return type is Result<T, E> | Result<T, F>.
I think it should just be Result<T, F>
Why?
My opinion, if it's Result::Ok, then map_err is no-op; the data (under user's scope) is only T, and we should be able to cast: return typing.cast(Result[T, F], self)
If it's Result::Err, wouldn't it forcefully go through fn and become F?
In the end, both branches yields Result<T, F>, there is no possibility of E for error type.
The same argument applies for Result::map as well.
Why is this relevant?
I'm trying to implement an equivalence of ? operator in Rust:
E=TypeVar('E', bound=BaseException)
T=TypeVar('T')
deferr_into(result: Result[T, E]) ->Result[T, str]:
# TYPE ERR: E@result is invariant: E@err_into cannot be assigned to `str`returnresult.map_err(lambdae: str(e))
The text was updated successfully, but these errors were encountered:
Love the python module! It makes my small codebase extremely simple and makes error handling much more sane!
What?
Though, I'm unable to get around the fact that
Result.map_err
has the effective func sig of:map_err :: Result<T, E> -> (E -> F) -> Result<T, E | F>
The original return type is
Result<T, E> | Result<T, F>
.I think it should just be
Result<T, F>
Why?
My opinion, if it's
Result::Ok
, thenmap_err
is no-op; the data (under user's scope) is onlyT
, and we should be able to cast:return typing.cast(Result[T, F], self)
If it's
Result::Err
, wouldn't it forcefully go throughfn
and becomeF
?In the end, both branches yields
Result<T, F>
, there is no possibility ofE
for error type.The same argument applies for
Result::map
as well.Why is this relevant?
I'm trying to implement an equivalence of
?
operator in Rust:The text was updated successfully, but these errors were encountered: