diff options
Diffstat (limited to 'ecs/src/pair.rs')
-rw-r--r-- | ecs/src/pair.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ecs/src/pair.rs b/ecs/src/pair.rs index 8bef70a..f9f76e7 100644 --- a/ecs/src/pair.rs +++ b/ecs/src/pair.rs @@ -542,6 +542,33 @@ pub struct MultipleWithWildcard<'a, Relation, Target> _pd: PhantomData<(Relation, Target)>, } +impl<'world, Relation, Target> MultipleWithWildcard<'world, Relation, Target> +{ + /// Returns a new `MultipleWithWildcard`. + /// + /// # Panics + /// This function will panic if: + /// - Both `Relation::uid()` and `Target::uid()` are wildcards + /// - Neither `Relation::uid()` or `Target::uid()` are wildcards + pub fn new(world: &'world World, entity_handle: EntityHandle<'world>) -> Self + where + Relation: ComponentOrWildcard, + Target: ComponentOrWildcard, + { + assert!(Relation::uid() == Wildcard::uid() || Target::uid() == Wildcard::uid()); + + assert!( + !(Relation::uid() == Wildcard::uid() && Target::uid() == Wildcard::uid()) + ); + + MultipleWithWildcard { + entity_handle, + world, + _pd: PhantomData, + } + } +} + impl<'a, Relation: Component> MultipleWithWildcard<'a, Relation, Wildcard> { #[must_use] |