| Crates.io | cabbage_collector |
| lib.rs | cabbage_collector |
| version | 0.1.1 |
| created_at | 2025-04-13 16:20:42.889059+00 |
| updated_at | 2025-05-10 18:57:24.821281+00 |
| description | ready |
| homepage | https://github.com/myyrakle/cabbage_collector/blob/master/README.md |
| repository | https://github.com/myyrakle/cabbage_collector |
| max_upload_size | |
| id | 1631957 |
| size | 12,671 |
The way to create and use the object is almost the same as Box<T>.
However, in the current implementation, GC must be triggered manually.
{
#[derive(Debug, Clone)]
struct A {
pub value: i32,
}
let child_obj = CabbageBox::new(A { value: 1 });
println!("{:?}", child_obj);
}
COLLECTOR.run_cabbage_collection();
The circular reference issue has been resolved.
{
#[derive(Debug, Clone)]
struct A {
pub value: Option<CabbageBox<B>>,
}
#[derive(Debug, Clone)]
struct B {
pub value: Option<CabbageBox<A>>,
}
let mut a_obj = CabbageBox::new(A { value: None });
let mut b_obj = CabbageBox::new(B { value: None });
a_obj.value = Some(b_obj.clone());
a_obj.adopt_child(b_obj.clone());
b_obj.value = Some(a_obj.clone());
b_obj.adopt_child(a_obj.clone());
}
COLLECTOR.run_cabbage_collection();