safe-gc
A garbage collection library for Rust without any unsafe
code
## About
`safe-gc` implements a garbage collection library for Rust with zero `unsafe`
code and zero dependencies. It even has a `forbid(unsafe_code)` directive at the
top!
Additional features:
* Allows constructing and collecting arbitrary heap graphs, including cycles. It
doesn't impose any ownership hierarchy, or anything like that, to the shapes
of references between GC-managed objects within the heap.
* Leverages Rust's ownership and borrowing in its API: if you have an `&mut
Heap`, you can get mutable access to objects in the heap. It doesn't, for
example, force everything in the heap into `RefCell`s, or only give out shared
references to GC-managed objects, or similar.
* Allows constructing multiple, separate GC heaps that can be independently
collected.
* Allows allocating any number of heterogeneous types within the heap. For
example, you can allocate both `Cons` and `Tree` objects within the
heap. Heaps are *not* constrained to only a single, uniform `T` type of GC
objects.
* Footgun-free GC object finalization with Rust's regular, old `Drop` trait. No
worries about accidentally deref'ing pointers to GC objects the collector has
already reclaimed or resurrecting objects it was about to reclaim.
`safe-gc` is not, however, a particularly high-performance garbage collector.
## Usage
* Define types managed by the GC.
* Define references from within one GC type to another GC type with `Gc