Skip to main content

EMPTY_VTABLE

Constant EMPTY_VTABLE 

Source
pub const EMPTY_VTABLE: NrosRmwVtable;
Expand description

A vtable with every slot NULL — the base for struct-update syntax.

Phase 376 W4 — a vtable literal must name EVERY field, and this crate’s tests build 26 of them. Adding a slot therefore meant adding one None, line to each, twenty-six times: tedious, and a place to miss one. The compiler catches a miss, but only after the diff has grown by the slot count times twenty-six. With this, a test names the slots it actually scripts and ends with ..EMPTY_VTABLE, so a new slot costs one line in the header and nothing here.

Deliberately a const and not a Default impl: Default would make an all-NULL vtable constructible by accident, and an all-NULL vtable is exactly what nros_rmw_cffi_register must REFUSE (issue 0349). A const used explicitly as a literal’s base cannot be reached that way.