Crates.io | cabbage_collector |
lib.rs | cabbage_collector |
version | |
source | src |
created_at | 2025-04-13 16:20:42.889059+00 |
updated_at | 2025-04-20 17:32:26.51465+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 |
Cargo.toml error: | TOML parse error at line 23, column 1 | 23 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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());
b_obj.value = Some(a_obj.clone());
}
COLLECTOR.run_cabbage_collection();