Skip to content
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

get type id from the trait object #85314

Closed
peacess opened this issue May 15, 2021 · 3 comments
Closed

get type id from the trait object #85314

peacess opened this issue May 15, 2021 · 3 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.

Comments

@peacess
Copy link

peacess commented May 15, 2021

pub fn get_data_type_id() TypeId
if add the fn , then we can safety convert trait1 object to trait2 object
trait1 object include data and vtable1
trait2 object include data and vtable2

data + vtable1 + get_data_type_id() + trait2 ==>(safety) trait2 object

@bjorn3
Copy link
Member

bjorn3 commented May 16, 2021

There are multiple ways to support downcasting trait objects to different trait objects. Each has different advantages and disadvantages. There has been a lot of discussion about this in the past, but no proposal has been accepted yet. By the way internals.rust-lang.org is a more suitable location to discuss changes to the rust language.

@crlf0710 crlf0710 added the C-discussion Category: Discussion or questions that doesn't represent real issues. label May 16, 2021
@jonas-schievink
Copy link
Contributor

Hi! Additions or changes to the language need to go through our RFC process. Before an RFC is written, the feature can also be discussed in our internals forum to find other people interested in it.

Closing in favor of an RFC.

@jonas-schievink
Copy link
Contributor

Trait object upcasting on the other hand is currently being implemented in #86264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues.
Projects
None yet
Development

No branches or pull requests

4 participants