clarify the docs of isolation (#17335)

* improve test coverage for isolation

* a bit better

* clarify the docs of isolation
This commit is contained in:
flywind 2021-03-11 21:04:08 +08:00 • committed by GitHub
commit d8b5879c7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -29,15 +29,21 @@ proc `=destroy`*[T](dest: var Isolated[T]) {.inline.} =
`=destroy`(dest.value) `=destroy`(dest.value)
func isolate*[T](value: sink T): Isolated[T] {.magic: "Isolate".} = func isolate*[T](value: sink T): Isolated[T] {.magic: "Isolate".} =
## Create an isolated subgraph from the expression `value`. ## Creates an isolated subgraph from the expression `value`.
## Isolation is checked at compile time.
##
## Please read https://github.com/nim-lang/RFCs/issues/244 ## Please read https://github.com/nim-lang/RFCs/issues/244
## for more details. ## for more details.
Isolated[T](value: value) Isolated[T](value: value)
func unsafeIsolate*[T](value: sink T): Isolated[T] = func unsafeIsolate*[T](value: sink T): Isolated[T] =
## Creates an isolated subgraph from the expression `value`. ## Creates an isolated subgraph from the expression `value`.
##
## .. warning:: The proc doesn't check whether `value` is isolated.
##
Isolated[T](value: value) Isolated[T](value: value)
func extract*[T](src: var Isolated[T]): T = func extract*[T](src: var Isolated[T]): T =
## Returns the internal value of `src`. ## Returns the internal value of `src`.
## The value is moved from `src`.
result = move(src.value) result = move(src.value)