Hacker News new | ask | show | jobs
by foldr 2879 days ago
You can do that if you change it to &Any and then downcast. See the docs for examples. If the issue is that you have to downcast, then your initial claim that Rust lacks void pointers was irrelevant even if true, since you also have to downcast a void pointer in C before you can perform operations on the type that it's actually pointing to.
2 comments

You can't downcast it to anything you want, it returns an Option, void pointers in C are not certainly the same, it's unsafe.
I know. That's why I said it's "a safe analogue of casting a void pointer to another type".
> If the issue is that you have to downcast

It's the difference between dynamic language and language with synthetic type for reflections.