Rust 语言之旅 目录

[未翻译] Dynamic vs Static Dispatch

Methods are executed in two ways:

Trait types &dyn MyTrait give us the ability to work with instances of objects indirectly using dynamic dispatch.

When dynamic dispatch is used, Rust will encourage you to put dyn before your trait type so people are aware.

Memory details: