Intermediate
Rust
Q41 / 100
What is the difference between static dispatch (generics) and dynamic dispatch (dyn Trait)?
Correct! Well done.
Incorrect.
The correct answer is B) Static dispatch inlines/monomorphizes for each concrete type (faster); dynamic dispatch uses vtable (slower but smaller binary, enables heterogeneous collections)
B
Correct Answer
Static dispatch inlines/monomorphizes for each concrete type (faster); dynamic dispatch uses vtable (slower but smaller binary, enables heterogeneous collections)
Explanation
fn f<T: Display>(x: T) is statically dispatched. fn g(x: &dyn Display) is dynamically dispatched via vtable indirection.
Progress
41/100