Deprecate getAll/getAllErrors in favour of valuesOf/errorsOf
This commit is contained in:
parent
7ce7c16d7f
commit
522c821fdf
@ -166,10 +166,19 @@ public fun <V, E> Iterable<Result<V, E>>.combine(): Result<List<V>, E> {
|
||||
*
|
||||
* - Haskell: [Data.Either.lefts](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Either.html#v:lefts)
|
||||
*/
|
||||
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.
|
||||
@ -191,6 +200,14 @@ public fun <V, E> Iterable<Result<V, E>>.getAll(): List<V> {
|
||||
*
|
||||
* - Haskell: [Data.Either.rights](https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Either.html#v:rights)
|
||||
*/
|
||||
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()
|
||||
}
|
||||
|
@ -113,11 +113,11 @@ class IterableTest {
|
||||
}
|
||||
}
|
||||
|
||||
class GetAll {
|
||||
class ValuesOf {
|
||||
|
||||
@Test
|
||||
fun returnsAllValues() {
|
||||
val result = getAll(
|
||||
val result = valuesOf(
|
||||
Ok("hello"),
|
||||
Ok("big"),
|
||||
Err(IterableError.IterableError2),
|
||||
@ -133,11 +133,11 @@ class IterableTest {
|
||||
}
|
||||
}
|
||||
|
||||
class GetAllErrors {
|
||||
class ErrorsOf {
|
||||
|
||||
@Test
|
||||
fun returnsAllErrors() {
|
||||
val result = getAllErrors(
|
||||
val result = errorsOf(
|
||||
Err(IterableError.IterableError2),
|
||||
Ok("haskell"),
|
||||
Err(IterableError.IterableError2),
|
||||
|
Loading…
Reference in New Issue
Block a user