kyren / gc-arena

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

Allow `Rootable` impls to have ?Sized Root types. #53

Closed kyren closed 1 week ago

kyren commented 1 year ago

Allows for dynamic rooting of unsized Gc pointers.

kyren commented 1 year ago

We could add a SizedRootable trait as an "alias" for requiring that the associated Root type be sized, if we considered it obnoxious to require for<'a> <R as Rootable<'a>>::Root: Sized everywhere, but realistically I don't think that many people are going to be writing Rootable bounds?

kyren commented 1 year ago

In https://github.com/kyren/deimos, this ended up being a bit more work than I thought due to the magic downcasting stuff there.

You would think it would just be adding : Sized bounds everywhere but for some reason I can't fully grasp, it made the compiler creak and groan a bit. I ended up having to drop a Sized bound on a Collect impl to make it work, and the error messages until I did that were extremely confusing and entirely about the 'gc lifetime and I'm not sure why. I don't fully understand why it wasn't exactly the same, but it's possible I just missed a different Sized bound somewhere or messed something else up.

Adding an alias trait might actually be a good idea if we merge this.

kyren commented 1 year ago

This is significantly less important now that #54 is merged, and in fact I don't know of a use case for it now?

kyren commented 1 year ago

You would think it would just be adding : Sized bounds everywhere but for some reason I can't fully grasp, it made the compiler creak and groan a bit. I ended up having to drop a Sized bound on a Collect impl to make it work, and the error messages until I did that were extremely confusing and entirely about the 'gc lifetime and I'm not sure why. I don't fully understand why it wasn't exactly the same, but it's possible I just missed a different Sized bound somewhere or messed something else up.

Probably ignore this, I think I may have just typoed a 'gc_ as 'gc somewhere, it didn't make sense that it happened and it may not have?.

kyren commented 1 week ago

superseded by #102