The `dyn` keyword marks a trait object, letting different concrete types be used through a shared trait interface. Rust uses a compiler-generated vtable for runtime dynamic dispatch. Trait objects are unsized, so store them behind a pointer such as `Box`; a `Vec` cannot hold `dyn MyTrait` directly. section 2.2.6 section 2.2.6
let mut v = Vec::<Box<dyn MyTrait>>::new();
v.push(Box::new(MyStruct1 {})); #1
v.push(Box::new(MyStruct2 {})); #2
v.iter().for_each(|i| i.trait_hello()); #3
// v.iter().for_each(|i| i.struct_hello()); error! #4
This vector stores two concrete types behind `Box<dyn MyTrait>` and calls their shared trait method. The concrete structs’ methods are not directly available through the trait object. section 2.2.6
