unroot
fn unroot<T>(Root<T> pin) -> Option<T> Import
Source: use gc::{unroot}; compiler/src/builtin_docs/gc.hy Releases the pin and returns the value it held.
After this the Root no longer keeps the value alive, even if the
Root itself is still reachable. A second unroot (or get) returns
None.
Parameters#
| Name | Type |
|---|---|
pin | Root<T> |
Returns#
Option<T>
Examples#
use gc::{root, unroot};
use tests::assert;
let pin = root("once");
assert!(match unroot(pin) { Option::Some(s) => s == "once", Option::None => false });
assert!(match unroot(pin) { Option::Some(_) => false, Option::None => true });
See also#
gc::Rootgc::getroot: Pinsvalueso the garbage collector keeps it alive while the returnedRootis reachable.weak: Makes a handle tovaluethat does not keep it alive.upgrade: Returns the value while it is still alive,Noneonce it was collected.heap_bytes: Returns the size of the managed heap in bytes.collect: Runs a full garbage collection now and returns the number of bytes freed.