liveBook · Manning

Dynamic dispatch

Dynamic dispatch is runtime selection of an operation implementation according to an object's dynamically determined type or runtime arguments.

How 2 Manning books explain it

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.

Read how Idiomatic Rust explains dynamic dispatch →

Related concepts

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.