Skip to content

Commit 75b21e9

Browse files
committed
*Buffer.use {}
1 parent 4881b7c commit 75b21e9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/main/kotlin/uno/buffer/buffer.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@ fun ByteBuffer.use(block: (ByteBuffer) -> Unit) {
8080
block(this)
8181
destroy()
8282
}
83+
fun ShortBuffer.use(block: (ShortBuffer) -> Unit) {
84+
block(this)
85+
destroy()
86+
}
87+
fun IntBuffer.use(block: (IntBuffer) -> Unit) {
88+
block(this)
89+
destroy()
90+
}
91+
fun LongBuffer.use(block: (LongBuffer) -> Unit) {
92+
block(this)
93+
destroy()
94+
}
95+
fun FloatBuffer.use(block: (FloatBuffer) -> Unit) {
96+
block(this)
97+
destroy()
98+
}
99+
fun DoubleBuffer.use(block: (DoubleBuffer) -> Unit) {
100+
block(this)
101+
destroy()
102+
}
103+
fun CharBuffer.use(block: (CharBuffer) -> Unit) {
104+
block(this)
105+
destroy()
106+
}
83107

84108
@Suppress("UNCHECKED_CAST")
85109
fun withBuffer(list: List<*>, block: ByteBuffer.() -> Unit) {

0 commit comments

Comments
 (0)