kyren / gc-arena

Incremental garbage collection from safe Rust
Creative Commons Zero v1.0 Universal
438 stars 36 forks source link

Basic support for `Gc` pointers to unsized types #35

Closed moulins closed 1 year ago

moulins commented 1 year ago

This rewrites the GcBox internals to use a manually-implemented vtable instead of relying on dyn Collect, enabling two improvements:

This could also allow removing the Self: Sized bound on Collect::needs_trace(), but this is technically a breaking change (making the trait non-object-safe) so idk if it should be done?

A small wrinkle though: unsized coercions for custom smart pointers aren't possible in stable Rust, so I've added an unsize!(gc => SomeUnsizedType) macro instead; feel free to bikeshed the syntax if you don't agree with my choice.