2 years ago
#45205

laptou
Is there a workaround for the fact that TypeId only works for 'static types?
I am giving C++ a Box
containing a trait object, and then when I get that Box<dyn Trait>
back from C++, I want to try to downcast it into a concrete type. However, I can't do it safely because the types I'm using are not (and cannot be) 'static
, so I can't use Any::downcast_ref
. Is there another way to assert that the cast that I'm doing is valid (ex.: is there a hack I can use to generate something like a TypeId
that ignores lifetime parameters)?
rust
ffi
rust
ffi
0 Answers
Your Answer