Dynamic dispatch
Dynamic dispatch is runtime selection of an operation implementation according to an object's dynamically determined type or runtime arguments.
Data-Oriented Programming: Reduce software complexity
Dynamic dispatch is runtime selection of an operation implementation based on runtime argument information rather than only static types.
- How it is used
- Uses runtime data to extend polymorphic behavior beyond single- and multiple-argument type selection.
- How deep it goes
- Explains dispatch functions, validation, emitted values, method wiring, defaults, and testing through a complete example.
- Examples
- Demonstrates dysGreet with dog, cat, and cow maps, combining animal type with whether a name exceeds five letters.
- What you can do after
- Build it from scratch with a dispatch function and methods keyed by runtime values.
Read how Data-Oriented Programming: Reduce software complexity explains dynamic dispatch →
Idiomatic Rust
Dynamic dispatch is runtime selection of an implementation based on the concrete type behind an interface value.
- How it is used
- Stores different concrete types behind one trait interface and calls shared trait methods at runtime.
- How deep it goes
- Explains `dyn` trait objects, vtable-based lookup, and pointer requirements for unsized values.
- Examples
- Demonstrates two structs in a boxed trait-object vector and dispatches their shared method.
- What you can do after
- Build a heterogeneous `Vec<Box<dyn MyTrait>>` and invoke the shared trait method.
Related concepts
- trait objectused by · A Rust trait object is a value accessed through a trait interface with its concrete implementing type hidden and methods dispatched dynamically.
- Boxused by · Box is a Rust owning smart pointer that provides indirection by storing a uniquely owned value in heap-allocated memory.
- vtableimplemented by · A vtable is a compiler- or runtime-generated table of function or method entries used to dynamically dispatch operations for polymorphic objects or types.
- polymorphismkind of · Polymorphism is a programming-language capability that lets a common interface or operation work with values of different types while allowing behavior to vary by type or implementation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

