Weak<T>
is a kind of #202111301656 that doesn’t possess ownership of a variable or an object and avoid 202206251349# that could be created from #202206232210 (especially RefCell<Rc<T>>
) by replacing #202206221720. It can be obtained from Rc<T>
with the method Rc::downgrade
. All Weak<T>
will be clean up once they are out of scope, regardless of the value of weak_count
(from Rc<T>
).
To test the validity of Weak<T>
, that is, whether it is pointing to a still alive variable, is to inspect the return value of the method Weak::upgrade
(it returns Option<Rc<T>>
) using match
.