Skip to content

Commit

Permalink
Remove deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbull committed Mar 16, 2024
1 parent f92d858 commit a9b9618
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 175 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand All @@ -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].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -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].
Expand Down

This file was deleted.

0 comments on commit a9b9618

Please sign in to comment.