Skip to content

Commit eecd1b7

Browse files
committed
Remove deprecated functions
1 parent 60769f9 commit eecd1b7

File tree

9 files changed

+0
-175
lines changed

9 files changed

+0
-175
lines changed

kotlin-result-coroutines/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/binding/SuspendableBinding.kt

-22
This file was deleted.

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/And.kt

-9
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ public infix fun <V, E, U> Result<V, E>.and(result: Result<U, E>): Result<U, E>
1515
}
1616
}
1717

18-
@Deprecated("Use andThen instead", ReplaceWith("andThen { result() }"))
19-
public inline infix fun <V, E, U> Result<V, E>.and(result: () -> Result<U, E>): Result<U, E> {
20-
contract {
21-
callsInPlace(result, InvocationKind.AT_MOST_ONCE)
22-
}
23-
24-
return andThen { result() }
25-
}
26-
2718
/**
2819
* Maps this [Result<V, E>][Result] to [Result<U, E>][Result] by either applying the [transform]
2920
* function if this result [is ok][Result.isOk], or returning [this].

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Binding.kt

-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@ public inline fun <V, E> binding(crossinline block: BindingScope<E>.() -> V): Re
4141

4242
internal expect object BindException : Exception
4343

44-
@Deprecated(
45-
message = "Use BindingScope instead",
46-
replaceWith = ReplaceWith("BindingScope<E>")
47-
)
48-
public typealias ResultBinding<E> = BindingScope<E>
49-
5044
public interface BindingScope<E> {
5145
public fun <V> Result<V, E>.bind(): V
5246
}

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Get.kt

-18
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ public infix fun <V, E> Result<V, E>.getOr(default: V): V {
5555
}
5656
}
5757

58-
@Deprecated("Use getOrElse instead", ReplaceWith("getOrElse { default() }"))
59-
public inline infix fun <V, E> Result<V, E>.getOr(default: () -> V): V {
60-
contract {
61-
callsInPlace(default, InvocationKind.AT_MOST_ONCE)
62-
}
63-
64-
return getOrElse { default() }
65-
}
66-
6758
/**
6859
* Returns the [error][Result.error] if this result [is an error][Result.isErr], otherwise
6960
* [default].
@@ -80,15 +71,6 @@ public infix fun <V, E> Result<V, E>.getErrorOr(default: E): E {
8071
}
8172
}
8273

83-
@Deprecated("Use getOrElse instead", ReplaceWith("getErrorOrElse { default() }"))
84-
public inline infix fun <V, E> Result<V, E>.getErrorOr(default: () -> E): E {
85-
contract {
86-
callsInPlace(default, InvocationKind.AT_MOST_ONCE)
87-
}
88-
89-
return getErrorOrElse { default() }
90-
}
91-
9274
/**
9375
* Returns the [value][Result.value] if this result [is ok][Result.isOk], otherwise the
9476
* [transformation][transform] of the [error][Result.error].

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Iterable.kt

-45
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,6 @@ public fun <V, E, R : Result<V, E>> valuesOf(vararg results: R): List<V> {
170170
return results.asIterable().filterValues()
171171
}
172172

173-
@Deprecated(
174-
message = "Use allValuesOf instead",
175-
replaceWith = ReplaceWith("valuesOf(results)")
176-
)
177-
public fun <V, E, R : Result<V, E>> getAll(vararg results: R): List<V> {
178-
return results.asIterable().filterValues()
179-
}
180-
181-
182-
/**
183-
* Extracts from an [Iterable] of [Results][Result] all the [Ok] elements. All the [Ok] elements
184-
* are extracted in order.
185-
*
186-
* - Haskell: [Data.Either.lefts](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Either.html#v:lefts)
187-
*/
188-
@Deprecated(
189-
message = "Use filterValues instead",
190-
replaceWith = ReplaceWith("filterValues()")
191-
)
192-
public fun <V, E> Iterable<Result<V, E>>.getAll(): List<V> {
193-
return filterValues()
194-
}
195-
196173
/**
197174
* Returns a [List] containing the [error][Result.error] of each element in the specified [results]
198175
* 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> {
204181
return results.asIterable().filterErrors()
205182
}
206183

207-
@Deprecated(
208-
message = "Use errorsOf instead",
209-
replaceWith = ReplaceWith("errorsOf(results)")
210-
)
211-
public fun <V, E, R : Result<V, E>> getAllErrors(vararg results: R): List<E> {
212-
return results.asIterable().filterErrors()
213-
}
214-
215-
/**
216-
* Extracts from an [Iterable] of [Results][Result] all the [Err] elements. All the [Err] elements
217-
* are extracted in order.
218-
*
219-
* - Haskell: [Data.Either.rights](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Either.html#v:rights)
220-
*/
221-
@Deprecated(
222-
message = "Use filterErrors instead",
223-
replaceWith = ReplaceWith("filterErrors()")
224-
)
225-
public fun <V, E> Iterable<Result<V, E>>.getAllErrors(): List<E> {
226-
return filterErrors()
227-
}
228-
229184
/**
230185
* Partitions the specified [results] into a [Pair] of [Lists][List]. An element that
231186
* [is ok][Result.isOk] will appear in the [first][Pair.first] list, whereas an element that

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Or.kt

-9
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ public infix fun <V, E, F> Result<V, E>.or(result: Result<V, F>): Result<V, F> {
1515
}
1616
}
1717

18-
@Deprecated("Use orElse instead", ReplaceWith("orElse { result() }"))
19-
public inline infix fun <V, E, F> Result<V, E>.or(result: () -> Result<V, F>): Result<V, F> {
20-
contract {
21-
callsInPlace(result, InvocationKind.AT_MOST_ONCE)
22-
}
23-
24-
return orElse { result() }
25-
}
26-
2718
/**
2819
* Returns the [transformation][transform] of the [error][Result.error] if this result
2920
* [is an error][Result.isErr], otherwise [this].

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Result.kt

-16
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,6 @@ public sealed class Result<out V, out E> {
5151

5252
public abstract operator fun component1(): V?
5353
public abstract operator fun component2(): E?
54-
55-
public companion object {
56-
57-
/**
58-
* Invokes a [function] and wraps it in a [Result], returning an [Err]
59-
* if an [Exception] was thrown, otherwise [Ok].
60-
*/
61-
@Deprecated("Use top-level runCatching instead", ReplaceWith("runCatching(function)"))
62-
public inline fun <V> of(function: () -> V): Result<V, Exception> {
63-
return try {
64-
Ok(function.invoke())
65-
} catch (ex: Exception) {
66-
Err(ex)
67-
}
68-
}
69-
}
7054
}
7155

7256
/**

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/Unwrap.kt

-18
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ public fun <V, E> Result<V, E>.unwrap(): V {
2424
}
2525
}
2626

27-
@Deprecated("Use lazy-evaluating variant instead", ReplaceWith("expect { message }"))
28-
public infix fun <V, E> Result<V, E>.expect(message: String): V {
29-
contract {
30-
returns() implies (this@expect is Ok<V>)
31-
}
32-
33-
return expect { message }
34-
}
35-
3627
/**
3728
* Returns the [value][Result.value] if this result [is ok][Result.isOk], otherwise throws an
3829
* [UnwrapException] with the specified [message].
@@ -75,15 +66,6 @@ public fun <V, E> Result<V, E>.unwrapError(): E {
7566
}
7667
}
7768

78-
@Deprecated("Use lazy-evaluating variant instead", ReplaceWith("expectError { message }"))
79-
public infix fun <V, E> Result<V, E>.expectError(message: String): E {
80-
contract {
81-
returns() implies (this@expectError is Err<E>)
82-
}
83-
84-
return expectError { message }
85-
}
86-
8769
/**
8870
* Returns the [error][Result.error] if this result [is an error][Result.isErr], otherwise throws
8971
* an [UnwrapException] with the specified [message].

kotlin-result/src/commonMain/kotlin/com/github/michaelbull/result/coroutines/SuspendableBinding.kt

-32
This file was deleted.

0 commit comments

Comments
 (0)