From 01c8c00f98dede60a4494f143b0c893a9fed5b1e Mon Sep 17 00:00:00 2001 From: Michael Bull Date: Fri, 8 Mar 2024 14:12:27 +0000 Subject: [PATCH] Rename error to result in binding impls --- .../result/coroutines/binding/SuspendableBinding.kt | 8 ++++---- .../kotlin/com/github/michaelbull/result/Binding.kt | 6 +++--- .../michaelbull/result/coroutines/SuspendableBinding.kt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt b/kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt index 13c5c59..f071ee9 100644 --- a/kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt +++ b/kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt @@ -33,7 +33,7 @@ public suspend inline fun binding(crossinline block: suspend SuspendableR with(receiver) { Ok(block()) } } } catch (ex: BindCancellationException) { - receiver.internalError + receiver.result } } @@ -49,14 +49,14 @@ internal class SuspendableResultBindingImpl( ) : SuspendableResultBinding { private val mutex = Mutex() - lateinit var internalError: Err + lateinit var result: Err override suspend fun Result.bind(): V { return when (this) { is Ok -> value is Err -> mutex.withLock { - if (::internalError.isInitialized.not()) { - internalError = this + if (::result.isInitialized.not()) { + result = this this@SuspendableResultBindingImpl.cancel(BindCancellationException) } diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Binding.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Binding.kt index 3e23ba9..6a5024c 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Binding.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Binding.kt @@ -32,7 +32,7 @@ public inline fun binding(crossinline block: ResultBinding.() -> V): R return try { with(receiver) { Ok(block()) } } catch (ex: BindException) { - receiver.error + receiver.result } } @@ -45,13 +45,13 @@ public interface ResultBinding { @PublishedApi internal class ResultBindingImpl : ResultBinding { - lateinit var error: Err + lateinit var result: Err override fun Result.bind(): V { return when (this) { is Ok -> value is Err -> { - this@ResultBindingImpl.error = this + this@ResultBindingImpl.result = this throw BindException } } diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/SuspendableBinding.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/SuspendableBinding.kt index 2784ec2..db3c9c7 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/SuspendableBinding.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/SuspendableBinding.kt @@ -27,6 +27,6 @@ public suspend inline fun binding(crossinline block: suspend ResultBindin return try { with(receiver) { Ok(block()) } } catch (ex: BindException) { - receiver.error + receiver.result } }