Starlight-JS / comet

Garbage collector library
MIT License
24 stars 5 forks source link

Traits in comet-extra #5

Closed segeljakt closed 2 years ago

segeljakt commented 2 years ago

I'm wondering, would it be possible to:

  1. impl Clone for comet_extra::alloc::string::String
  2. impl Clone for comet_extra::alloc::vector::Vector
  3. impl Collectable for comet_extra::alloc::vector::Vector

I get around 1 & 2 by wrapping them in Gc<T, _>. I cannot get around 3 though.

playXE commented 2 years ago

3 is possible. For 1 and 2 we would probably need to add GcClone trait into comet itself and a derive macro to make GcClone work. The main problem is that to clone GCed values we need to allocate memory for them