pub trait VTable<T> {
// Required method
fn build_vtable() -> Self;
}
Expand description
VTable
defines a type that represents a virtual function table for some type T
.
T
is different than a type that can be turned into a trait object like Box<dyn Any>
because a VTable
effectively decouples the type’s behaviour from the data it contains.
This mechanism allows the virtual function table to be attached to a homogeneous container, to prevent storing duplicates of these tables for each type instance stored in the container.
This is precisely how it is used to build VecDyn<V>
, which is generic over the virtual table
rather than the type itself.
Required Methods§
fn build_vtable() -> Self
Object Safety§
This trait is not object safe.