Merge pull request #3 from kevinherron/inline-on-functions

Inline the onSuccess() and onFailure() functions
This commit is contained in:
Michael Bull 2017-12-16 22:26:39 +00:00 committed by GitHub
commit 5dc5d3680e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)