gjh33
gjh33

Reputation: 37

How to have different implementation for tuple of references vs tuple of values

I'm trying to write an ECS system that can query components by value, reference, or mutable reference. For this, I want a different implementation for various tuple types as an Archetype.

trait Archetype { /* bla bla */ }
impl<C> Archetype for (C,) where C: Component {}
impl<C> Archetype for (&C,) where C: Component {} // Error, conflicts with previous impl
impl<C> Archetype for (&mut C,) where C: Component {} // Error conflicts with first impl

My guess is because rust is interpreting the "C" in the first impl to be any type that implements component, including "&C" and "&mut C". If I remove the first impl, the other two won't conflict. Is there a way to have that first impl and specify it's for owned types only?

Upvotes: 1

Views: 72

Answers (0)

Related Questions