Kotlin / kotlinx.collections.immutable

Immutable persistent collections for Kotlin
Apache License 2.0
1.12k stars 56 forks source link

Add `buildPersistentList { }`, `buildPersistentMap { }`, `buildPersistentSet { }` to match the builders in kotlin stdlib #137

Open yogurtearl opened 1 year ago

yogurtearl commented 1 year ago

Add buildPersistentList { }, buildPersistentMap { }, buildPersistentSet { } to match the collection builders in kotlin stdlib

I would imagine it would look something like this:

fun <E> buildPersistentList(block: PersistentList.Builder<E>.() -> Unit): PersistentList<E> = 
    persistentListOf<E>().builder().apply(block).build() 
Shusek commented 1 year ago

I think it's a good idea but it should be inlined because otherwise it doesn't work at @Composable functions.

Goooler commented 6 months ago

Addressing the fix to #166, can you take a review?