Downcast a non-‘static type

⚓ rust    📅 2025-05-09    👤 surdeus    👁️ 5      

surdeus

Warning

This post was published 53 days ago. The information described in this article may have changed.

Is there any way to downcast from dyn Trait to the original type for types that don’t implement Any? I know for sure that my value is of the correct type so I don’t really need to check the type ID, and as far as I can tell the rest is just a simple transmute. But I’m assuming that the transmute is an implementation detail that I shouldn’t rely on, is there any official way of doing this?

Edit: a short example of what I mean.

9 posts - 4 participants

Read full topic

🏷️ rust_feed