pub struct Conformance { /* private fields */ }Expand description
A synthesized conformance, kept alive for the process’s lifetime.
Implementations§
Source§impl Conformance
impl Conformance
Sourcepub fn descriptor(&self) -> *const c_void
pub fn descriptor(&self) -> *const c_void
The conformance descriptor the runtime was handed.
Only of interest when checking that a lookup found this conformance rather than one the framework already had.
Sourcepub fn witness_table(&self) -> *const c_void
pub fn witness_table(&self) -> *const c_void
The witness table, ready to pass as a generic argument.
Sourcepub unsafe fn patch(&self, slot: usize, witness: *const c_void)
pub unsafe fn patch(&self, slot: usize, witness: *const c_void)
Fill a witness in after the fact.
For a conformance that cannot be complete when it is built. Shape
requires View, and a shape’s View.Body is
_ShapeView<Self, ForegroundStyle> — whose metadata needs Self: Shape.
Neither table can be finished before the other exists, so the Shape one
is registered with its View slot empty, the metadata is instantiated
against it, and the slot is filled here. Swift resolves the same knot with
lazy witness tables; this is the same trick with the laziness written out.
§Safety
slot must be within the protocol’s requirement count, witness must be
the right kind of thing for it, and nothing may have used the slot yet —
a witness table the runtime has already cached a lookup for is still
readable, so writing to it is only safe before anything dispatches through
that entry.