katokay
11/05/2024, 2:25 PMkotlinx.cinterop.staticCFunction must take an unbound, non-capturing function or lambda, but captures at
actual fun dbiOpen(name: String?, comparator: Comparator<Val>, vararg options: DbiOption) : Dbi {
val db = Dbi(name, this, *options)
check(mdb_set_compare(ptr, db.dbi, staticCFunction { left, right ->
comparator.compare(Val.forCompare(left!!.pointed), Val.forCompare(right!!.pointed))
}))
return db
}
Project is located here: https://github.com/CoreyKaylor/kotlin-lmdb
Any help would be appreciated if there is another creative way to provide this minor abstraction for the end-user.katokay
11/12/2024, 11:12 PMLamberto Basti
11/13/2024, 10:57 PMFile.useLines
:
public inline fun <T> File.useLines(charset: Charset = Charsets.UTF_8, block: (Sequence<String>) -> T): T =
bufferedReader(charset).use { block(it.lineSequence()) }
The problem here is that the stream has to be closed once finished using the sequence. Same gos for my case and I assume for yours too. Have a look at my implementation! I will probably helpLamberto Basti
11/13/2024, 11:00 PMkatokay
11/14/2024, 1:55 PMkatokay
11/14/2024, 1:58 PM