Trait Objects: Goodbye virtual, Hello dyn

Trait Objects: Goodbye virtual, Hello dyn

Welcome to Day 30 and today we are going to explore how Rust handles dynamic dispatch with trait objects. If you are used to the world of C# this is the part where you usually reach for abstract classes or virtual methods. Maybe you sprinkle in some interfaces and let polymorphism do the heavy lifting at runtime.

In Rust dynamic dispatch works a little differently and it is all thanks to dyn.