Struct vtable::VRef

source · []
#[repr(transparent)]
pub struct VRef<'a, T: ?Sized + VTableMeta> { /* private fields */ }
Expand description

VRef<'a MyTraitVTable> can be thought as a &'a dyn MyTrait

It will dereference to a structure that has the same members as MyTrait.

Implementations

Create a new VRef from an reference of a type that can be associated with a VTable.

(the HasStaticVTable is implemented by the “MyTrait”VTable_static! macro generated by the #vtable macro)

Create a new Pin<VRef<_>> from a pinned reference. This is similar to VRef::new.

Create a new VRef from raw pointers

Safety

The ptr needs to be a valid object fitting the vtable. Both vtable and ptr lifetime must outlive ’a

Return a reference of the given type if the type is matching.

Return a reference of the given type if the type is matching

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.