Skip to main content

custom_data_vtable

Function custom_data_vtable 

Source
pub fn custom_data_vtable<T>() -> *const CustomDataVTable
Expand description

Returns a &'static CustomDataVTable for the given PluginCustomData type.

One static vtable per concrete T. The vtable lives in const-promoted static storage attached to a PhantomData<T>-tagged generic struct, so each monomorphisation gets its own table.

Naive static FOO: OnceLock<CustomDataVTable> = OnceLock::new() inside a generic function is unsound here: when FOO’s type does not mention T, Rust shares the static across every monomorphisation and the first initializer wins, so every later type collapses onto the first type’s thunks.