#[repr(transparent)]
pub struct VBox<T: ?Sized + VTableMetaDrop> { /* private fields */ }
Expand description

An equivalent of a Box that holds a pointer to a VTable and a pointer to an instance. A VBox frees the instance when dropped.

The type parameter is supposed to be the VTable type.

The VBox implements Deref so one can access all the members of the vtable.

This is only valid if the VTable has a drop function (so that the #[vtable] macro implements the VTableMetaDrop trait for it)

Implementations

Create a new VBox from an instance of a type that can be associated with a VTable.

Will move the instance on the heap.

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

Create a new VBox from raw pointers

Safety

The ptr needs to be a valid object fitting the vtable. ptr must be properly allocated so it can be dropped.

Gets a VRef pointing to this box

Gets a VRefMut pointing to this box

Leaks the content of the box.

Trait Implementations

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Executes the destructor for this type. Read more

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 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.