Merge pull request #3 from kevinherron/inline-on-functions
Inline the onSuccess() and onFailure() functions
This commit is contained in:
commit
5dc5d3680e
@ -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