macro_rules! unsafe_trace_primitive {
    ($target:ty) => { ... };
    ($target:ty; @ $(deserialize => $strategy:ident)?) => { ... };
}
Expand description

Unsafely implement GarbageCollected for the specified type, by assuming it’s a ‘primitive’ and never needs to be traced.

The fact that this type is a ‘primitive’ means it’s assumed to have no type parameters, and that there’s nothing . This macro is only useful for unsafe types like String who use raw pointers internally, since raw pointers can’t be automatically traced without additional type information.

Safety

Always prefer automatically derived implementations where possible, since they’re just as fast and can never cause undefined behavior. This is basically an unsafe automatically derived implementation, to be used only when a safe automatically derived implementation isn’t possible (like with String).

Undefined behavior only if there are garbage collected pointers in the type’s interior, since the implementation assumes there’s nothing to trace in the first place.

This delegates to unsafe_gc_impl! to provide the (GcRebrand)crate::GcRebrand implementation, but that will never cause undefined behavior unless you already have garbage collected pointers inside (which are already undefined behavior for tracing).