blob: e0b84a28399680304051e7c2d5672cc52e7568e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
* Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.dokka.utilities
import org.jetbrains.dokka.InternalDokkaApi
/**
* This utility method was previously imported from `org.jetbrains.kotlin.utils.addToStdlib`,
* and there were a lot of usages. Since no replacement exists in stdlib, it was implemented
* locally for convenience.
*/
@InternalDokkaApi
public inline fun <reified T : Any> Iterable<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}
/**
* This utility method was previously imported from `org.jetbrains.kotlin.utils.addToStdlib`,
* and there were a lot of usages. Since no replacement exists in stdlib, it was implemented
* locally for convenience.
*/
@InternalDokkaApi
public inline fun <reified T : Any> Sequence<*>.firstIsInstanceOrNull(): T? {
for (element in this) if (element is T) return element
return null
}
|