weak
fn weak<T>(T value) -> Weak<T> Import
Source: use gc::{weak}; compiler/src/builtin_docs/gc.hy Makes a handle to value that does not keep it alive.
Values that are not heap objects (int, bool, float, …) are never
collected, so their Weak always upgrades. value can be of any type:
a weak of an Option or a Result refers to the heap object it holds.
Parameters#
| Name | Type |
|---|---|
value | T |
Returns#
Weak<T>
Examples#
use gc::{weak, upgrade};
use tests::assert;
let w = weak(5);
assert!(match upgrade(w) { Option::Some(n) => n == 5, Option::None => false });