Skip to content

Expose type_name() method on Any. #68379

Open
@rickvanprim

Description

@rickvanprim

In a similar spirit to #61533, it would be nice if the Any trait contained an auto implemented method akin to:

fn type_name(&self) -> &'static str
{
    std::any::type_name::<T>()
}

This way it would be a lot easier print and surface errors like accidentally trying to cast Box<T> to T because &Box<T> is also &Any.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-intrinsicsArea: IntrinsicsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions