quark-zju / gcmodule

Garbage collection for Rust inspired by CPython's gcmodule
MIT License
20 stars 5 forks source link

Box<dyn _> #9

Open mio-19 opened 4 years ago

mio-19 commented 4 years ago

fix https://github.com/quark-zju/gcmodule/issues/8

quark-zju commented 4 years ago

This removes an optimization. The old code will not track types like Box<T> where T is known to be untracked. That means Cc<Box<T>> won't be inserted to the linked list and Cc<Box<T>> takes less space in memory.

Could you use the customize type instead? That is, define struct MyBox(Box<dyn MyTrait>) and implement Trace on MyBox. That would preserve the optimization and makes Cc<MyBox> compile.