From 12bd661c7c6ec40a2cb8946567db958e8d19a8d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernd=20Pr=C3=BCnster?= Date: Tue, 18 Jun 2024 16:29:24 +0200 Subject: [PATCH] prepare next release --- CHANGELOG.md | 3 ++- gradle.properties | 2 +- src/commonMain/kotlin/at/asitplus/KmmResult.kt | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7e6988..3b54735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,8 @@ ## 1.6.2 - `wrapping` function, which wraps any exception as the specified type -## Next +## 1.7.0 - add `out` qualifier to KmmResult's type parameter - add `recoverCatching` to match Kotlin's `result` - add `callsInPlace` contracts +- return result fon `onFailure` and `onSuccess` diff --git a/gradle.properties b/gradle.properties index fb991c2..33765e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ kotlin.mpp.enableCInteropCommonization=true kotlin.mpp.stability.nowarn=true kotlin.native.ignoreDisabledTargets=true -artifactVersion = 1.6.2 \ No newline at end of file +artifactVersion = 1.7.0 \ No newline at end of file diff --git a/src/commonMain/kotlin/at/asitplus/KmmResult.kt b/src/commonMain/kotlin/at/asitplus/KmmResult.kt index 4aec050..d2a4249 100644 --- a/src/commonMain/kotlin/at/asitplus/KmmResult.kt +++ b/src/commonMain/kotlin/at/asitplus/KmmResult.kt @@ -186,21 +186,23 @@ private constructor( /** * singular version of `fold`'s `onSuccess` */ - inline fun onSuccess(block: (value: T) -> R) { + inline fun onSuccess(block: (value: T) -> R): KmmResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) } if (isSuccess) block(getOrThrow()) + return this } /** * singular version of `fold`'s `onFailure` */ - inline fun onFailure(block: (error: Throwable) -> R) { + inline fun onFailure(block: (error: Throwable) -> R): KmmResult { contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) } exceptionOrNull()?.let { block(it) } + return this } /**