Expand description

Derive Weak

Implements derive macro #[derive(Weak)] which creates ‘weak’ counterpart for the structure. I.e. when original structure contains reference counting pointers (Arc, Rc), the corresponding weak structure contains the weak variants of these pointers (std::sync::Weak, std::rc::Weak).

This may be useful when it’s inconvenient to store some data under refernce counting pointer, due to performance or ergonomic reasons.

Derive Macros

#[derive(Weak)] for struct type Foo generates new type WFoo (name can be changed) with reference counting fields replaced to their non-owning (weak) pairs. Methods downgrade() -> WFoo and upgrade() -> Option<Foo> added to Foo and WFoo respectively.