use cpp_oop::gen_oop; gen_oop! { #[default] struct Foo { foo: u32, } struct FooLayout { foo: fn(this: &Self, a: i32) -> u32, } impl FooMethodsInner for Foo { extern "C" fn foo_inner(_this: &Self, _a: i32) -> u32 { 1 } } } #[test] fn layout() { assert_eq!(std::mem::size_of::(), std::mem::size_of::()); } #[test] fn basic() { let f = Foo::default(); let f_ptr = &f as *const Foo; assert_eq!(Foo::foo_inner(&f, 0), 1); // manual selection of the method to call assert_eq!(f.foo(0), 1); // static dispatch assert_eq!(f_ptr.foo(0), 1); // this one has no vtable (no virtual methods) so it will use static dispatch }