summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorflywind <xzsflywind@gmail.com>2021-03-05 23:21:33 +0800
committerGitHub <noreply@github.com>2021-03-05 16:21:33 +0100
commit19be5eb1ebfc92c66ebf39c81c46209df734e89f (patch)
tree8bf0ea182f4e6d8fb195f8406ba07d606af39152
parentb2b23d723afde51d54a63d1c19e0ae04d6d826c7 (diff)
downloadNim-19be5eb1ebfc92c66ebf39c81c46209df734e89f.tar.gz
Add unsafeIsolate and extract to std/isolation [backport:1.4] (#17263)
-rw-r--r--changelog.md2
-rw-r--r--lib/std/isolation.nim8
2 files changed, 10 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index d19cac926..6081c90b1 100644
--- a/changelog.md
+++ b/changelog.md
@@ -252,6 +252,8 @@ provided by the operating system.
 
 - `--newruntime` and `--refchecks` are deprecated.
 
+- Added `unsafeIsolate` and `extract` to `std/isolation`.
+
 ## Tool changes
 
 - The rst parser now supports markdown table syntax.
diff --git a/lib/std/isolation.nim b/lib/std/isolation.nim
index 7c44f47fb..70395d6d4 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)