vtable in macros
The kernel calls a driver through a struct full of function pointers, and it leaves an entry null when the driver does not implement that operation. Rust traits have no nulls, because every method ca…
The kernel calls drivers through structures full of function pointers, with unimplemented entries left null so the caller can take a faster path. A Rust trait has no nulls, so an attribute on the trait generates, for each method, a constant saying whether this implementation provided it, letting the generated table match C's expectations exactly. A second attribute marks a Rust function so that C code may call it by name. Together they are the seam between the two languages, and knowing they exist explains why the traits you implement look the way they do.
The kernel calls a driver through a struct full of function pointers, and it leaves an entry null when the driver does not implement that operation. Rust traits have no nulls, because every method ca…