re-init-rc
This crate provides two wrappers for Rc and Arc weak pointers - ReInitRc
and ReInitArc
, both types provides an API to get a pointer (Rc
or Arc
) from inner weak pointer (upgrade) or re-create the value using the provided function (if inner weak pointer points to a dropped value).
The API is:
And same for ReInitArc
but ReInitArc::get
returns Arc<T>
Example with ReInitRc
(ReInitArc
works the same way)
The code:
use ReInitRc;
;
Outputs:
Initializing new PrintOnDrop...
Printing on drop
Initializing new PrintOnDrop...
Printing on drop