remove crossinline where possible

This commit is contained in:
InsanusMokrassar 2021-12-08 11:41:49 +06:00
parent acf4971298
commit bdac715d48
2 changed files with 9 additions and 9 deletions

View File

@ -129,7 +129,7 @@ inline fun <T1, T2> Either.Companion.second(t2: T2): Either<T1, T2> = EitherSeco
/** /**
* Will call [block] in case when [Either.t1] of [this] is not null * Will call [block] in case when [Either.t1] of [this] is not null
*/ */
inline fun <T1, T2, E : Either<T1, T2>> E.onFirst(crossinline block: (T1) -> Unit): E { inline fun <T1, T2, E : Either<T1, T2>> E.onFirst(block: (T1) -> Unit): E {
val t1 = t1 val t1 = t1
t1 ?.let(block) t1 ?.let(block)
return this return this
@ -138,7 +138,7 @@ inline fun <T1, T2, E : Either<T1, T2>> E.onFirst(crossinline block: (T1) -> Uni
/** /**
* Will call [block] in case when [Either.t2] of [this] is not null * Will call [block] in case when [Either.t2] of [this] is not null
*/ */
inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(crossinline block: (T2) -> Unit): E { inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(block: (T2) -> Unit): E {
val t2 = t2 val t2 = t2
t2 ?.let(block) t2 ?.let(block)
return this return this

View File

@ -1,10 +1,10 @@
package dev.inmo.micro_utils.common package dev.inmo.micro_utils.common
inline fun <I, R> Iterable<I>.joinTo( inline fun <I, R> Iterable<I>.joinTo(
crossinline separatorFun: (I) -> R?, separatorFun: (I) -> R?,
prefix: R? = null, prefix: R? = null,
postfix: R? = null, postfix: R? = null,
crossinline transform: (I) -> R? transform: (I) -> R?
): List<R> { ): List<R> {
val result = mutableListOf<R>() val result = mutableListOf<R>()
val iterator = iterator() val iterator = iterator()
@ -29,11 +29,11 @@ inline fun <I, R> Iterable<I>.joinTo(
separator: R? = null, separator: R? = null,
prefix: R? = null, prefix: R? = null,
postfix: R? = null, postfix: R? = null,
crossinline transform: (I) -> R? transform: (I) -> R?
): List<R> = joinTo({ separator }, prefix, postfix, transform) ): List<R> = joinTo({ separator }, prefix, postfix, transform)
inline fun <I> Iterable<I>.joinTo( inline fun <I> Iterable<I>.joinTo(
crossinline separatorFun: (I) -> I?, separatorFun: (I) -> I?,
prefix: I? = null, prefix: I? = null,
postfix: I? = null postfix: I? = null
): List<I> = joinTo<I, I>(separatorFun, prefix, postfix) { it } ): List<I> = joinTo<I, I>(separatorFun, prefix, postfix) { it }
@ -45,15 +45,15 @@ inline fun <I> Iterable<I>.joinTo(
): List<I> = joinTo<I>({ separator }, prefix, postfix) ): List<I> = joinTo<I>({ separator }, prefix, postfix)
inline fun <I, reified R> Array<I>.joinTo( inline fun <I, reified R> Array<I>.joinTo(
crossinline separatorFun: (I) -> R?, separatorFun: (I) -> R?,
prefix: R? = null, prefix: R? = null,
postfix: R? = null, postfix: R? = null,
crossinline transform: (I) -> R? transform: (I) -> R?
): Array<R> = asIterable().joinTo(separatorFun, prefix, postfix, transform).toTypedArray() ): Array<R> = asIterable().joinTo(separatorFun, prefix, postfix, transform).toTypedArray()
inline fun <I, reified R> Array<I>.joinTo( inline fun <I, reified R> Array<I>.joinTo(
separator: R? = null, separator: R? = null,
prefix: R? = null, prefix: R? = null,
postfix: R? = null, postfix: R? = null,
crossinline transform: (I) -> R? transform: (I) -> R?
): Array<R> = asIterable().joinTo(separator, prefix, postfix, transform).toTypedArray() ): Array<R> = asIterable().joinTo(separator, prefix, postfix, transform).toTypedArray()