[python]: PY-85585 : (WIP) Introduce method to map errors

Utility method to map `Result<S, E>`` into `Result<S, E2>`` is required for the next changes

(cherry picked from commit 811ddf171794ffdf20f77de6c735ac7ac19ce30a)

GitOrigin-RevId: b13ddca080644357a738ffc10795703d11b18d97
This commit is contained in:
Ilya.Kazakevich
2025-11-26 13:52:46 +00:00
committed by intellij-monorepo-bot
parent 60804a8248
commit ed0fda649a
@@ -186,3 +186,9 @@ val <S, E> Result<S, E>.isFailure: Boolean get() = this is Failure
val <S, E> Result<S, E>.isSuccess: Boolean get() = this is Success
fun <S, E> Result<S, E>.getOrThrow(): S = orThrow()
/**
* See [Result.mapSuccess]
*/
inline fun <S, E, E2> Iterable<Result<S, E>>.mapError(code: (E) -> E2): List<Result<S, E2>> =
map { it.mapError(code) }