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 deleted file mode 100644 index ed61b42..0000000 --- a/kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.github.michaelbull.result.coroutines.binding - -import com.github.michaelbull.result.Result -import com.github.michaelbull.result.coroutines.CoroutineBindingScope -import com.github.michaelbull.result.coroutines.coroutineBinding - -@Deprecated( - message = "Use coroutineBinding instead", - replaceWith = ReplaceWith( - expression = "coroutineBinding(block)", - imports = ["com.github.michaelbull.result.coroutines.coroutineBinding"] - ) -) -public suspend inline fun binding(crossinline block: suspend CoroutineBindingScope.() -> V): Result { - return coroutineBinding(block) -} - -@Deprecated( - message = "Use CoroutineBindingScope instead", - replaceWith = ReplaceWith("CoroutineBindingScope") -) -public typealias SuspendableResultBinding = CoroutineBindingScope diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/And.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/And.kt index 23efe49..000dca8 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/And.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/And.kt @@ -15,15 +15,6 @@ public infix fun Result.and(result: Result): Result } } -@Deprecated("Use andThen instead", ReplaceWith("andThen { result() }")) -public inline infix fun Result.and(result: () -> Result): Result { - contract { - callsInPlace(result, InvocationKind.AT_MOST_ONCE) - } - - return andThen { result() } -} - /** * Maps this [Result][Result] to [Result][Result] by either applying the [transform] * function if this [Result] is [Ok], or returning this [Err]. 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 d723656..cf4c9c3 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 @@ -38,12 +38,6 @@ public inline fun binding(crossinline block: BindingScope.() -> V): Re internal expect object BindException : Exception -@Deprecated( - message = "Use BindingScope instead", - replaceWith = ReplaceWith("BindingScope") -) -public typealias ResultBinding = BindingScope - public interface BindingScope { public fun Result.bind(): V } diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Get.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Get.kt index ecdb26b..92f242a 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Get.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Get.kt @@ -55,15 +55,6 @@ public infix fun Result.getOr(default: V): V { } } -@Deprecated("Use getOrElse instead", ReplaceWith("getOrElse { default() }")) -public inline infix fun Result.getOr(default: () -> V): V { - contract { - callsInPlace(default, InvocationKind.AT_MOST_ONCE) - } - - return getOrElse { default() } -} - /** * Returns the [error][Err.error] if this [Result] is [Err], otherwise [default]. * @@ -79,15 +70,6 @@ public infix fun Result.getErrorOr(default: E): E { } } -@Deprecated("Use getOrElse instead", ReplaceWith("getErrorOrElse { default() }")) -public inline infix fun Result.getErrorOr(default: () -> E): E { - contract { - callsInPlace(default, InvocationKind.AT_MOST_ONCE) - } - - return getErrorOrElse { default() } -} - /** * Returns the [value][Ok.value] if this [Result] is [Ok], otherwise the * [transformation][transform] of the [error][Err.error]. diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Iterable.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Iterable.kt index c68d950..6b71f23 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Iterable.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Iterable.kt @@ -163,20 +163,6 @@ public fun > getAll(vararg results: R): List { return results.asIterable().filterValues() } -/** - * Extracts from an [Iterable] of [Results][Result] all the [Ok] elements. All the [Ok] elements - * are extracted in order. - * - * - Haskell: [Data.Either.lefts](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Either.html#v:lefts) - */ -@Deprecated( - message = "Use filterValues instead", - replaceWith = ReplaceWith("filterValues()") -) -public fun Iterable>.getAll(): List { - return filterValues() -} - /** * Extracts from a vararg of [Results][Result] all the [Err] elements. All the [Err] elements are * extracted in order. @@ -187,20 +173,6 @@ public fun > getAllErrors(vararg results: R): List { return results.asIterable().filterErrors() } -/** - * Extracts from an [Iterable] of [Results][Result] all the [Err] elements. All the [Err] elements - * are extracted in order. - * - * - Haskell: [Data.Either.rights](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Either.html#v:rights) - */ -@Deprecated( - message = "Use filterErrors instead", - replaceWith = ReplaceWith("filterErrors()") -) -public fun Iterable>.getAllErrors(): List { - return filterErrors() -} - /** * Partitions a vararg of [Results][Result] into a [Pair] of [Lists][List]. All the [Ok] elements * are extracted, in order, to the [first][Pair.first] value. Similarly the [Err] elements are diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Or.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Or.kt index fc4063a..e845ceb 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Or.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Or.kt @@ -15,15 +15,6 @@ public infix fun Result.or(result: Result): Result { } } -@Deprecated("Use orElse instead", ReplaceWith("orElse { result() }")) -public inline infix fun Result.or(result: () -> Result): Result { - contract { - callsInPlace(result, InvocationKind.AT_MOST_ONCE) - } - - return orElse { result() } -} - /** * Returns the [transformation][transform] of the [error][Err.error] if this [Result] is [Err], * otherwise this [Ok]. diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Result.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Result.kt index 3541325..a306f78 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Result.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Result.kt @@ -8,25 +8,8 @@ package com.github.michaelbull.result * - Rust: [Result](https://doc.rust-lang.org/std/result/enum.Result.html) */ public sealed class Result { - public abstract operator fun component1(): V? public abstract operator fun component2(): E? - - public companion object { - - /** - * Invokes a [function] and wraps it in a [Result], returning an [Err] - * if an [Exception] was thrown, otherwise [Ok]. - */ - @Deprecated("Use top-level runCatching instead", ReplaceWith("runCatching(function)")) - public inline fun of(function: () -> V): Result { - return try { - Ok(function.invoke()) - } catch (ex: Exception) { - Err(ex) - } - } - } } /** diff --git a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Unwrap.kt b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Unwrap.kt index 283fbbb..76844cd 100644 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Unwrap.kt +++ b/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Unwrap.kt @@ -23,15 +23,6 @@ public fun Result.unwrap(): V { } } -@Deprecated("Use lazy-evaluating variant instead", ReplaceWith("expect { message }")) -public infix fun Result.expect(message: String): V { - contract { - returns() implies (this@expect is Ok) - } - - return expect { message } -} - /** * Unwraps a [Result], yielding the [value][Ok.value]. * @@ -70,15 +61,6 @@ public fun Result.unwrapError(): E { } } -@Deprecated("Use lazy-evaluating variant instead", ReplaceWith("expectError { message }")) -public infix fun Result.expectError(message: String): E { - contract { - returns() implies (this@expectError is Err) - } - - return expectError { message } -} - /** * Unwraps a [Result], yielding the [error][Err.error]. * 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 deleted file mode 100644 index 93a9c02..0000000 --- a/kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/SuspendableBinding.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.github.michaelbull.result.coroutines - -import com.github.michaelbull.result.BindException -import com.github.michaelbull.result.BindingScope -import com.github.michaelbull.result.BindingScopeImpl -import com.github.michaelbull.result.Ok -import com.github.michaelbull.result.Result -import kotlin.contracts.InvocationKind -import kotlin.contracts.contract - -/** - * Suspending variant of [binding][com.github.michaelbull.result.binding]. - */ -@Deprecated( - message = "Will throw a runtime exception if used with async requests that fail to bind. " + - "See https://github.com/michaelbull/kotlin-result/pull/28 " + - "Please import the kotlin-result-coroutines library to continue using this feature.", - level = DeprecationLevel.WARNING -) -public suspend inline fun binding(crossinline block: suspend BindingScope.() -> V): Result { - contract { - callsInPlace(block, InvocationKind.EXACTLY_ONCE) - } - - return with(BindingScopeImpl()) { - try { - Ok(block()) - } catch (ex: BindException) { - result!! - } - } -}