Skip to main content

pure_virtual

Attribute Macro pure_virtual 

Source
#[pure_virtual]
Expand description

Marks a method as a virtual function at a given index in the vtable. Methods marked with this must be part of a type that implements HasVtable, and must take &self or &mut self as the first parameter. The method body is replaced with a call to the function pointer at the specified index in the vtable

§Example

#[derive(forge::HasVtable)]
pub struct MyStruct;

impl MyStruct {
    #[forge::pure_virtual(3)]
    pub fn my_virtual_func(&self) -> i32 {}
}

Note the lack of an actual implementation of the function.