Skip to content

Add an extension trait for TypeIdMap to query values using generics #19642

Closed
@Shatur

Description

@Shatur

What problem does this solve or what need does it fill?

I can get values from TypeIdMap like this:

map.get(&TypeId::of::<MyType>());
map.remove(TypeId::of::<MyType>());

But it's not very ergonomic and requires importing TypeId.

What solution would you like?

Since we already have an alias with faster hasher, I'd suggest to create an extension trait to allow the following:

map.get_type:<MyType>();
map.remove_type:<MyType>();

And maybe for other similar methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UtilsUtility functions and typesC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-TrivialNice and easy! A great choice to get started with BevyS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions