Skip to content

Commit 93ce4d8

Browse files
authored
[core] Add Sync.Unsafe.ensure overload for AllowUnsafe finalizers (#1477)
`Sync.Unsafe.ensure` that automatically provides `AllowUnsafe` for the finalizer.
1 parent 1e81e09 commit 93ce4d8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kyo-core/shared/src/main/scala/kyo/Sync.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ object Sync:
119119
f(using AllowUnsafe.embrace.danger)
120120
}
121121

122+
inline def ensure[A, S](inline f: AllowUnsafe ?=> Any < (Sync & Abort[Throwable]))(v: => A < S)(using
123+
inline frame: Frame
124+
): A < (Sync & S) =
125+
Sync.ensure(f(using AllowUnsafe.embrace.danger))(v)
126+
122127
def withLocal[A, B, S](local: Local[A])(f: AllowUnsafe ?=> A => B < S)(using Frame): B < (S & Sync) =
123128
local.use(f(using AllowUnsafe.embrace.danger))
124129

0 commit comments

Comments
 (0)