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?
impl for Tconflicting withimpl for &T, you probably need negative bounds, which is still only a proposal as of the time of writing. For the needs of ECS specifically, you may wish to take a look at how Bevy does things (specifically,ResandResMut).