pub unsafe trait ErasableGeneric {
type Repr;
}Expand description
Private marker trait for erasable generics - types with this trait have the same repr for all generic param values, and can therefore be transmuted on the singular Repr type representation on ABI boundaries.
§Safety
This type must only be implemented on types known to be repr equivalent to their Repr type.
Required Associated Types§
Sourcetype Repr
type Repr
The singular concrete type that all generic variants can be transmuted on.
For reference types this deliberately carries the borrow lifetime (rather
than erasing it to 'static). The lifetime-faithful repr is what makes
Upcast::upcast and
upcast_into sound: the
Repr-equality bound then rejects upcasts that would launder a
short-lived borrow into a longer one. The 'static erasure that the JS
ABI boundary relies on (where borrows are only ever call-scoped) is
instead performed explicitly via an unsafe cast in codegen.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".