From f5fe442cc8d00315f8c3feda81ee0f0983100e0f Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 16 Aug 2021 16:00:38 +0800 Subject: [PATCH] Add simple constructor for `TypeSafeMap` --- mirai-core-utils/src/commonMain/kotlin/TypeSafeMap.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mirai-core-utils/src/commonMain/kotlin/TypeSafeMap.kt b/mirai-core-utils/src/commonMain/kotlin/TypeSafeMap.kt index fe1cb0177..21326a184 100644 --- a/mirai-core-utils/src/commonMain/kotlin/TypeSafeMap.kt +++ b/mirai-core-utils/src/commonMain/kotlin/TypeSafeMap.kt @@ -113,6 +113,10 @@ public inline fun MutableTypeSafeMap(): MutableTypeSafeMap = MutableTypeSafeMapI public inline fun MutableTypeSafeMap(map: Map): MutableTypeSafeMap = MutableTypeSafeMapImpl().also { it.map.putAll(map) } +public inline fun TypeSafeMap(): TypeSafeMap = MutableTypeSafeMapImpl() +public inline fun TypeSafeMap(map: Map): TypeSafeMap = + MutableTypeSafeMapImpl().also { it.map.putAll(map) } + public inline fun buildTypeSafeMap(block: MutableTypeSafeMap.() -> Unit): MutableTypeSafeMap { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } return MutableTypeSafeMapImpl().apply(block)