mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-24 06:50:08 +08:00
Add contract
This commit is contained in:
parent
ff2f0b5ae3
commit
70201af1c8
@ -1,7 +1,17 @@
|
||||
package net.mamoe.mirai.qqandroid.utils
|
||||
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.InvocationKind
|
||||
import kotlin.contracts.contract
|
||||
|
||||
/**
|
||||
* Inline the block
|
||||
*/
|
||||
@UseExperimental(ExperimentalContracts::class)
|
||||
@PublishedApi
|
||||
internal inline fun <R> inline(block: () -> R): R = block()
|
||||
internal inline fun <R> inline(block: () -> R): R {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
}
|
||||
return block()
|
||||
}
|
Loading…
Reference in New Issue
Block a user