Remove deprecated functions

This commit is contained in:
Michael Bull 2024-03-05 15:16:31 +00:00
parent 60769f9983
commit eecd1b7d99
9 changed files with 0 additions and 175 deletions

View File

@ -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 <V, E> binding(crossinline block: suspend CoroutineBindingScope<E>.() -> V): Result<V, E> {
return coroutineBinding(block)
}
@Deprecated(
message = "Use CoroutineBindingScope instead",
replaceWith = ReplaceWith("CoroutineBindingScope<E>")
)
public typealias SuspendableResultBinding<E> = CoroutineBindingScope<E>

View File

@ -15,15 +15,6 @@ public infix fun <V, E, U> Result<V, E>.and(result: Result<U, E>): Result<U, E>
}
}
@Deprecated("Use andThen instead", ReplaceWith("andThen { result() }"))
public inline infix fun <V, E, U> Result<V, E>.and(result: () -> Result<U, E>): Result<U, E> {
contract {
callsInPlace(result, InvocationKind.AT_MOST_ONCE)
}
return andThen { result() }
}
/**
* Maps this [Result<V, E>][Result] to [Result<U, E>][Result] by either applying the [transform]
* function if this result [is ok][Result.isOk], or returning [this].

View File

@ -41,12 +41,6 @@ public inline fun <V, E> binding(crossinline block: BindingScope<E>.() -> V): Re
internal expect object BindException : Exception
@Deprecated(
message = "Use BindingScope instead",
replaceWith = ReplaceWith("BindingScope<E>")
)
public typealias ResultBinding<E> = BindingScope<E>
public interface BindingScope<E> {
public fun <V> Result<V, E>.bind(): V
}

View File

@ -55,15 +55,6 @@ public infix fun <V, E> Result<V, E>.getOr(default: V): V {
}
}
@Deprecated("Use getOrElse instead", ReplaceWith("getOrElse { default() }"))
public inline infix fun <V, E> Result<V, E>.getOr(default: () -> V): V {
contract {
callsInPlace(default, InvocationKind.AT_MOST_ONCE)
}
return getOrElse { default() }
}
/**
* Returns the [error][Result.error] if this result [is an error][Result.isErr], otherwise
* [default].
@ -80,15 +71,6 @@ public infix fun <V, E> Result<V, E>.getErrorOr(default: E): E {
}
}
@Deprecated("Use getOrElse instead", ReplaceWith("getErrorOrElse { default() }"))
public inline infix fun <V, E> Result<V, E>.getErrorOr(default: () -> E): E {
contract {
callsInPlace(default, InvocationKind.AT_MOST_ONCE)
}
return getErrorOrElse { default() }
}
/**
* Returns the [value][Result.value] if this result [is ok][Result.isOk], otherwise the
* [transformation][transform] of the [error][Result.error].

View File

@ -170,29 +170,6 @@ public fun <V, E, R : Result<V, E>> valuesOf(vararg results: R): List<V> {
return results.asIterable().filterValues()
}
@Deprecated(
message = "Use allValuesOf instead",
replaceWith = ReplaceWith("valuesOf(results)")
)
public fun <V, E, R : Result<V, E>> getAll(vararg results: R): List<V> {
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 <V, E> Iterable<Result<V, E>>.getAll(): List<V> {
return filterValues()
}
/**
* Returns a [List] containing the [error][Result.error] of each element in the specified [results]
* that [is an error][Result.isErr]. Elements in the returned list are in the same order as the
@ -204,28 +181,6 @@ public fun <V, E, R : Result<V, E>> errorsOf(vararg results: R): List<E> {
return results.asIterable().filterErrors()
}
@Deprecated(
message = "Use errorsOf instead",
replaceWith = ReplaceWith("errorsOf(results)")
)
public fun <V, E, R : Result<V, E>> getAllErrors(vararg results: R): List<E> {
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 <V, E> Iterable<Result<V, E>>.getAllErrors(): List<E> {
return filterErrors()
}
/**
* Partitions the specified [results] into a [Pair] of [Lists][List]. An element that
* [is ok][Result.isOk] will appear in the [first][Pair.first] list, whereas an element that

View File

@ -15,15 +15,6 @@ public infix fun <V, E, F> Result<V, E>.or(result: Result<V, F>): Result<V, F> {
}
}
@Deprecated("Use orElse instead", ReplaceWith("orElse { result() }"))
public inline infix fun <V, E, F> Result<V, E>.or(result: () -> Result<V, F>): Result<V, F> {
contract {
callsInPlace(result, InvocationKind.AT_MOST_ONCE)
}
return orElse { result() }
}
/**
* Returns the [transformation][transform] of the [error][Result.error] if this result
* [is an error][Result.isErr], otherwise [this].

View File

@ -51,22 +51,6 @@ public sealed class Result<out V, out E> {
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 <V> of(function: () -> V): Result<V, Exception> {
return try {
Ok(function.invoke())
} catch (ex: Exception) {
Err(ex)
}
}
}
}
/**

View File

@ -24,15 +24,6 @@ public fun <V, E> Result<V, E>.unwrap(): V {
}
}
@Deprecated("Use lazy-evaluating variant instead", ReplaceWith("expect { message }"))
public infix fun <V, E> Result<V, E>.expect(message: String): V {
contract {
returns() implies (this@expect is Ok<V>)
}
return expect { message }
}
/**
* Returns the [value][Result.value] if this result [is ok][Result.isOk], otherwise throws an
* [UnwrapException] with the specified [message].
@ -75,15 +66,6 @@ public fun <V, E> Result<V, E>.unwrapError(): E {
}
}
@Deprecated("Use lazy-evaluating variant instead", ReplaceWith("expectError { message }"))
public infix fun <V, E> Result<V, E>.expectError(message: String): E {
contract {
returns() implies (this@expectError is Err<E>)
}
return expectError { message }
}
/**
* Returns the [error][Result.error] if this result [is an error][Result.isErr], otherwise throws
* an [UnwrapException] with the specified [message].

View File

@ -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 <V, E> binding(crossinline block: suspend BindingScope<E>.() -> V): Result<V, E> {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return with(BindingScopeImpl<E>()) {
try {
Ok(block())
} catch (ex: BindException) {
result!!
}
}
}