JoJoJet / bevy-trait-query

adds trait queries to the bevy game engine
Apache License 2.0
65 stars 11 forks source link

Is `register_component_as` idempotent? #3

Closed TimJentzsch closed 1 year ago

TimJentzsch commented 1 year ago

For my (a bit hacky) use-case of bevy-trait-query, I need to register a generic struct as a trait, for different generic variants that I can't know in advance.

Hence, I need to call register_component_as for certain user actions and cannot guarantee that the combination of generics is different every time.

Is register_component_as idempotent, i.e., is it fine to call it multiple times for the same combination of trait-component combinations?

JoJoJet commented 1 year ago

It definitely should be fine to call multiple times. It returns early if you try to register an impl twice.

I should clarify this in the docs and add a test case, though.