Inline the onSuccess() and onFailure() functions
This commit is contained in:
parent
80c6410181
commit
47fa20ca34
@ -4,10 +4,10 @@ package com.github.michaelbull.result
|
|||||||
* Calls a [callback] if the [Result] is [Ok].
|
* Calls a [callback] if the [Result] is [Ok].
|
||||||
* @param callback The function to call.
|
* @param callback The function to call.
|
||||||
*/
|
*/
|
||||||
fun <V, E> Result<V, E>.onSuccess(callback: (V) -> Unit) = mapBoth(callback, {})
|
inline fun <V, E> Result<V, E>.onSuccess(callback: (V) -> Unit) = mapBoth(callback, {})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls a [callback] if the [Result] is [Err].
|
* Calls a [callback] if the [Result] is [Err].
|
||||||
* @param callback The function to call.
|
* @param callback The function to call.
|
||||||
*/
|
*/
|
||||||
fun <V, E> Result<V, E>.onFailure(callback: (E) -> Unit) = mapBoth({}, callback)
|
inline fun <V, E> Result<V, E>.onFailure(callback: (E) -> Unit) = mapBoth({}, callback)
|
||||||
|
Loading…
Reference in New Issue
Block a user