mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[fleet] replace takeTillFirst with takeUntilInclusive
GitOrigin-RevId: 21b9bbbdfbfd10d3b2508f286282d77769442a7e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
635cb95299
commit
71ec005d4e
@@ -1,9 +1,6 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package fleet.util
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.transformWhile
|
||||
|
||||
/**
|
||||
* Same idea as [kotlin.collections.singleOrNull] but will throw if the collection contains more than one element.
|
||||
* */
|
||||
@@ -35,13 +32,6 @@ inline fun <T> Iterable<T>.singleOrNullOrThrowWithMessage(errorMessage: () -> St
|
||||
return single
|
||||
}
|
||||
|
||||
inline fun <T> Flow<T>.takeTillFirst(crossinline predicate: (T) -> Boolean): Flow<T> {
|
||||
return this@takeTillFirst.transformWhile {
|
||||
emit(it)
|
||||
!predicate(it)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> Iterable<T>.takeTillFirst(crossinline predicate: (T) -> Boolean): Iterable<T> {
|
||||
val list = ArrayList<T>()
|
||||
for (item in this) {
|
||||
|
||||
Reference in New Issue
Block a user