From 6b004630746b8cd0905f5b40191147ecc7bf082c Mon Sep 17 00:00:00 2001 From: flywind Date: Fri, 5 Mar 2021 23:21:33 +0800 Subject: [PATCH] Add unsafeIsolate and extract to std/isolation [backport:1.4] (#17263) (cherry picked from commit 19be5eb1ebfc92c66ebf39c81c46209df734e89f) --- changelog.md | 2 ++ lib/std/isolation.nim | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/changelog.md b/changelog.md index 4edb3474221e1..bf2fe163202ef 100644 --- a/changelog.md +++ b/changelog.md @@ -44,5 +44,7 @@ +- Added `unsafeIsolate` and `extract` to `std/isolation`. + ## Tool changes diff --git a/lib/std/isolation.nim b/lib/std/isolation.nim index 7c44f47fb6e33..70395d6d496be 100644 --- a/lib/std/isolation.nim +++ b/lib/std/isolation.nim @@ -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)