Skip to content

get type id from the trait object #85314

Closed

Description

@peacess

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

Activity

  1. bjorn3 commented on May 16, 2021

    @bjorn3
    Member

    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.

  2. added
    C-discussionCategory: Discussion or questions that doesn't represent real issues.
    on May 16, 2021
  3. jonas-schievink commented on Jun 30, 2021

    @jonas-schievink
    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.

  4. jonas-schievink commented on Jun 30, 2021

    @jonas-schievink
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions