kyren / gc-arena

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

Add `Gc::as_ref` to get a `&'gc T` from a `Gc<'gc, T>` #66

Closed moulins closed 1 year ago

moulins commented 1 year ago

(also, add impl AsRef for Gc, and remove extra borrows from other Gc-taking methods)

This is sound, as &'gc T doesn't implement Collect (unless 'gc ends up being 'static, which will be impossible once #63 is merged) and so cannot escape the current arena callback by being stored in the GC root.