A trait for garbage collected objects that can be placed into `Gc` pointers. This trait is unsafe, because `Gc` pointers inside an Arena are assumed never to be dangling, and in order to ensure this certain rules must be followed: 1. `Collect::trace` *must* trace over *every* `Gc` pointer held inside this type, and cannot fail. 2. Held `Gc` pointers must not be accessed inside `Drop::drop` since
| 21 | /// while ensuring that the write barrier is always executed. |
| 22 | /// # Safety |
| 23 | pub unsafe trait Collect { |
| 24 | /// As an optimization, if this type can never hold a `Gc` pointer and `trace` is unnecessary |
| 25 | /// to call, you may implement this method and return false. The default implementation returns |
| 26 | /// true, signaling that `Collect::trace` must be called. |
| 27 | #[inline] |
| 28 | fn needs_trace() -> bool |
| 29 | where |
| 30 | Self: Sized, |
| 31 | { |
| 32 | true |
| 33 | } |
| 34 | |
| 35 | /// *Must* call `Collect::trace` on all held `Gc` pointers. If this type holds inner types that |
| 36 | /// implement `Collect`, a valid implementation would simply call `Collect::trace` on all the |
| 37 | /// held values to ensure this. |
| 38 | #[inline] |
| 39 | fn trace(&self, _cc: &Collection) {} |
| 40 | } |
nothing calls this directly
no outgoing calls
no test coverage detected