Inline the onSuccess() and onFailure() functions

This commit is contained in:
Kevin Herron 2017-12-16 14:12:07 -08:00
parent 80c6410181
commit 47fa20ca34

View File

@ -4,10 +4,10 @@ package com.github.michaelbull.result
* Calls a [callback] if the [Result] is [Ok].
* @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].
* @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)