# `dumpster`: A cycle-tracking garbage collector for Rust
`dumpster` is an cycle-detecting garbage collector for Rust.
It detects unreachable allocations and automatically frees them.
## Why should you use this crate?
In short, `dumpster` offers a great mix of usability, performance, and flexibility.
- `dumpster`'s API is a drop-in replacement for `std`'s reference-counted shared allocations
(`Rc` and `Arc`).
- It's very performant and has builtin implementations of both thread-local and concurrent
garbage collection.
- There are no restrictions on the reference structure within a garbage-collected allocation
(references may point in any way you like).
- It's trivial to make a custom type Trace using the provided derive macros.
- You can even store `?Sized` data in a garbage-collected pointer!
## How it works
`dumpster` is unlike most tracing garbage collectors.
Other GCs keep track of a set of roots, which can then be used to perform a sweep and find out
which allocations are reachable and which are not.
Instead, `dumpster` extends reference-counted garbage collection (such as `std::rc::Rc`) with a
cycle-detection algorithm, enabling it to effectively clean up self-referential data structures.
For a deeper dive, check out this
[blog post](https://claytonwramsey.github.io/2023/08/14/dumpster.html).
## What this library contains
`dumpster` actually contains two garbage collector implementations: one thread-local, non-`Send`
garbage collector in the module `unsync`, and one thread-safe garbage collector in the module
`sync`.
These garbage collectors can be safely mixed and matched.
This library also comes with a derive macro for creating custom Trace types.
## Examples
```rust
use dumpster::{Trace, unsync::Gc};
#[derive(Trace)]
struct Foo {
ptr: RefCell