-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rustonomicon] Show how to convert a trait object into concrete type #28571
Comments
/cc @gankro |
I was under the impression that the lang team (cc @nikomatsakis -- can't ping lang myself) wasn't happy with std::raw::TraitObject, so I'm kinda iffy about talking about it. Especially because this is a really specific usecase that's kinda sketchy right now. IDK. Maybe @aturon's inheritance stuff is the way forward? |
That's what I was under the impression of too
|
Yes, we don't have a stable, recommended way to do this at the moment. Ultimately, we plan to support "upcasting" in traits (so that if you have |
Okay! Giving this a close, then. |
Last night somebody asked how to convert a trait object where they knew the concrete type into the concrete type. I tried looking for the answer in the Rustonomicon, but alas, no answer was found. Should this be in there?
The answer has to do with transmuting into
std::raw::TraitObject
. Even if it's just a link to that type from the transmutation page, I think it's important to explicitly show that it is possible. One issue though, is that std::raw::TraitObject is currently unstable as per issue #27751.The text was updated successfully, but these errors were encountered: