Closed Ralith closed 2 years ago
While I have not formed an opinion of whether this simplifies explaining things (In my mental model, World::get(_mut)
were the primitives out of which the queries are built via their DSL.), I wanted to add that the query combinators potentially have a similar foot gun, e.g. Query<With<(&R, &S), &T>>
does not work as one might expect and the correct Query<With<(&R, &S), T>>
might be surprising. (I guess it isn't completely the same as &T
and &mut T
imply no difference for the query combinator.)
I've received many independent user reports of footgun-related injuries here, so I'm convinced of the benefit.
With
/Without
are an interesting point. I've also been a bit unhappy with how they have to be nested to consider multiple components. Maybe we should refactor those to operate on two queries, rather than a query and a component type? Logically equivalent to the 2-tuple combinator, except that the results for the second item are not yielded (or borrowed).
Maybe we should refactor those to operate on two queries, rather than a query and a component type?
This sounds sensible and would also be nicely consistent with Satisfies
.
Comically, I have just now discovered a bug in my own project that this would have prevented. Will probably publish a release soon.
Many users have reported confusion arising from the use of component types in
World::get
in contrast to the use of reference sinWorld::query
and friends. This replacesget
andget_mut
onWorld
andEntityRef
with a singleget
that is generic over references to components, so that the intuitive thing Just Works, and passing an explicit component type generates a trait error.For consistency,
EntityBuilder:;get
andget_mut
are both refactored similarly, although they cannot be combined into a single method as they do not perform dynamic borrow checking.This also resolves the inconsistency between
get_mut
referring to the mutability of the component borrow, while other_mut
methods onWorld
instead refer to the mutability of the world borrow.