get
fn get<T>(Root<T> pin) -> Option<T> Import
Source: use gc::{get}; compiler/src/builtin_docs/gc.hy Returns the pinned value, leaving the pin in place.
Returns None after unroot has released the pin.
Parameters#
| Name | Type |
|---|---|
pin | Root<T> |
Returns#
Option<T>
Examples#
use gc::{root, get, unroot};
use tests::assert;
let pin = root(7);
assert!(match get(pin) { Option::Some(n) => n == 7, Option::None => false });
let _ = unroot(pin);
assert!(match get(pin) { Option::Some(_) => false, Option::None => true });
See also#
gc::unrootroot: 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.