Add unsafeIsolate and extract to std/isolation [backport:1.4] (#17263)

(cherry picked from commit 19be5eb1eb)
This commit is contained in:
flywind
2021-03-05 23:21:33 +08:00
committed by narimiran
parent e996d98a8a
commit 6b00463074
2 changed files with 10 additions and 0 deletions

View File

@@ -44,5 +44,7 @@
- Added `unsafeIsolate` and `extract` to `std/isolation`.
## Tool changes

View File

@@ -30,3 +30,11 @@ func isolate*[T](value: sink T): Isolated[T] {.magic: "Isolate".} =
## Please read https://github.com/nim-lang/RFCs/issues/244
## for more details.
Isolated[T](value: value)
func unsafeIsolate*[T](value: sink T): Isolated[T] =
## Creates an isolated subgraph from the expression `value`.
Isolated[T](value: value)
func extract*[T](src: var Isolated[T]): T =
## Returns the internal value of `src`.
result = move(src.value)