1. 8
  1. 2

    I’ve never needed to downcast in Rust. This seems like a major anti-pattern to me. Perhaps it’s just more familiar to people used to OO languages or Go? I would say ADTs and/or trait bounds should be used instead.

    1. 2

      The only place I’ve used downcasting myself is with Python interop via PyO3. When you have an arbitrary object and want to do an attribute lookup Rust has no knowledge of the specific types contained in the attributes. The attribute lookup returns a PyObject or something along those lines, and you either live with that PyObject or downcast it into a more specific type because you have some out of band knowledge that the compiler doesn’t.