Cycle collecting reference counted pointers for Rust with a safe api.
This crate is most useful when you have a data structure with inter-dependent nodes of arbitrary lifetimes and no clear parent-children relationships.
If you can be certain that the layout of your data will be acyclic, or [std::rc::Weak
]
would be sufficient to prevent leaks, this type is probably not a good fit. If you know all
of your data will be dropped after a certain phase of your program completes, you will
probably prefer arena allocation through a crate like typed-arena
, generational-arena
,
etc.
Concurrent Collection
Experimental support for concurrent collection may be enabled with the sync
feature flag. When
enabled, a sync::Agc
type will be provided, paralleling std::sync::Arc
. Note that you will
need to call sync::collect
instead of rc::collect
to collect garbage generated by Agc
values.
Basic Example
# use ;
#
#