Skip to main content

Conformance

Struct Conformance 

Source
pub struct Conformance { /* private fields */ }
Expand description

A synthesized conformance, kept alive for the process’s lifetime.

Implementations§

Source§

impl Conformance

Source

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.

Source

pub fn witness_table(&self) -> *const c_void

The witness table, ready to pass as a generic argument.

Source

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.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.