Skip to content
Latchkey

What Is Trait Object Dispatch?

Trait object dispatch is a form of dynamic dispatch where a value is accessed behind an interface pointer paired with a table of method implementations for its concrete type. At each call the runtime follows the table to the right function rather than the compiler choosing it. This allows heterogeneous types to be used uniformly through one interface.

Why it matters

Dynamic dispatch enables flexible, plugin-style designs where the concrete type is not known until runtime. The trade-off against static dispatch is a small indirection cost and fewer inlining opportunities.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →