Trait objects expose only the methods declared by their trait. Downcasting can recover a concrete type when you need to call one of its other methods. To obtain a reference, add an `as_any(&self) -> &dyn Any` method to the trait and implement it by returning `self`. section 2.2.6
Call `downcast_ref::<T>()` on the returned `Any` reference; it yields an optional reference to the value if its concrete type is `T`. `Any` requires `'static` types. Box, Rc, and Arc also support consuming downcasts, while `Any` allows borrowing. Use this escape hatch carefully rather than relying on concrete-type checks throughout dynamic dispatch. section 2.2.6
println!("With a downcast:");
v.iter().for_each(|i| { #1
if let Some(obj) = i.as_any().downcast_ref::<MyStruct1>() {
obj.struct_hello();
}
if let Some(obj) = i.as_any().downcast_ref::<MyStruct2>() {
obj.struct_hello();
}
});
The example checks each trait object for two concrete types and calls the matching type-specific method. section 2.2.6

