How to downcast from trait object

A common question. :wink:
That's what the Any trait is for, but for ergonomics, one still needs to implement methods on the trait that you intend to downcast. There are many crates that provide macros to implement these methods on a trait:

I had a long thread back in December trying to wrap my mind around why other crates used unsafe code underneath. I learned that it was unnecessary and wrote the downcast-rs crate using only safe code.