Fixed unused exceptionOrNull result in map/mapCatching
(replaced with isSuccess check)
This commit is contained in:
@@ -227,8 +227,8 @@ public inline fun <R, T> Result<T>.map(transform: (value: T) -> R): Result<R> {
|
|||||||
contract {
|
contract {
|
||||||
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
|
callsInPlace(transform, InvocationKind.AT_MOST_ONCE)
|
||||||
}
|
}
|
||||||
return when(val exception = exceptionOrNull()) {
|
return when {
|
||||||
null -> Result.success(transform(value as T))
|
isSuccess -> Result.success(transform(value as T))
|
||||||
else -> Result(value)
|
else -> Result(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,8 +243,8 @@ public inline fun <R, T> Result<T>.map(transform: (value: T) -> R): Result<R> {
|
|||||||
*/
|
*/
|
||||||
@InlineOnly
|
@InlineOnly
|
||||||
public inline fun <R, T> Result<T>.mapCatching(transform: (value: T) -> R): Result<R> {
|
public inline fun <R, T> Result<T>.mapCatching(transform: (value: T) -> R): Result<R> {
|
||||||
return when(val exception = exceptionOrNull()) {
|
return when {
|
||||||
null -> runCatching { transform(value as T) }
|
isSuccess -> runCatching { transform(value as T) }
|
||||||
else -> Result(value)
|
else -> Result(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user